Skip to content

Commit 923502d

Browse files
zhu-xiaoweixiaoweii
andauthored
feat: change base64 format with no_wrap (#12)
--------- Co-authored-by: xiaoweii <xiaoweii@amazom.com>
1 parent fa5c52c commit 923502d

File tree

4 files changed

+19
-2
lines changed

4 files changed

+19
-2
lines changed

clickstream/src/main/java/software/aws/solution/clickstream/client/AutoRecordEventClient.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ private void checkAppVersionUpdate() {
120120
this.clickstreamContext.getAnalyticsClient().createEvent(Event.PresetEvent.APP_UPDATE);
121121
event.addAttribute(Event.ReservedAttribute.PREVIOUS_APP_VERSION, previousAppVersion);
122122
this.clickstreamContext.getAnalyticsClient().recordEvent(event);
123+
clickstreamContext.getSystem().getPreferences().putString("appVersion", currentVersion);
123124
}
124125
} else {
125126
clickstreamContext.getSystem().getPreferences()
@@ -139,6 +140,7 @@ private void checkOSVersionUpdate() {
139140
this.clickstreamContext.getAnalyticsClient().createEvent(Event.PresetEvent.OS_UPDATE);
140141
event.addAttribute(Event.ReservedAttribute.PREVIOUS_OS_VERSION, previousOSVersion);
141142
this.clickstreamContext.getAnalyticsClient().recordEvent(event);
143+
clickstreamContext.getSystem().getPreferences().putString("osVersion", currentOSVersion);
142144
}
143145
} else {
144146
clickstreamContext.getSystem().getPreferences()

clickstream/src/main/java/software/aws/solution/clickstream/client/util/StringUtil.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public static String compressForGzip(String ungzipStr) {
5757
LOG.error("IOException occur when compressForGzip.");
5858
}
5959
if (encode != null) {
60-
return Base64.encodeToString(encode, Base64.DEFAULT);
60+
return Base64.encodeToString(encode, Base64.NO_WRAP);
6161
} else {
6262
LOG.error("compressForGzip fail.");
6363
return null;

clickstream/src/test/java/software/aws/solution/clickstream/util/StringUtilTest.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,4 +134,19 @@ public void clipStringForAppendEllipses() {
134134
assertTrue(StringUtil.clipString("abcdefgh", 5, true).endsWith("..."));
135135
assertFalse(StringUtil.clipString("abcdefgh", 10, true).endsWith("..."));
136136
}
137+
138+
/**
139+
* test validate gzip with no wrap.
140+
*/
141+
@Test
142+
public void validateGzipWithNoWrap() {
143+
String str = "abcdeabcde";
144+
StringBuilder sb = new StringBuilder();
145+
for (int i = 0; i < 100; i++) {
146+
sb.append(str);
147+
}
148+
String gzippedStr = StringUtil.compressForGzip(sb.toString());
149+
assert gzippedStr != null;
150+
assertFalse(gzippedStr.contains("\n"));
151+
}
137152
}

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ org.gradle.jvmargs=-Xmx4g
1212
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
1313
org.gradle.parallel=true
1414

15-
VERSION_NAME=0.4.0
15+
VERSION_NAME=0.4.1
1616

1717
POM_GROUP=software.aws.solution
1818
POM_ARTIFACT_ID=clickstream

0 commit comments

Comments
 (0)