You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by "wu-sheng (via GitHub)" <gi...@apache.org> on 2023/06/25 06:17:29 UTC
[GitHub] [skywalking] wu-sheng commented on a diff in pull request #10990: fix: Limit the length of Event#parameters(#10263)
wu-sheng commented on code in PR #10990:
URL: https://github.com/apache/skywalking/pull/10990#discussion_r1241049386
##########
oap-server/server-library/library-util/src/test/java/org/apache/skywalking/oap/server/library/util/StringUtilTest.java:
##########
@@ -76,4 +76,12 @@ public void testTrim() {
assertEquals(StringUtil.trim("abcdef", 'a'), "bcdef");
assertEquals(StringUtil.trim("abcdef", 'f'), "abcde");
}
+
+ @Test
+ public void testTrimJson() {
+ String jsonString = "{\"k1\":\"v1\",\"k2\":\"v2\",\"k3\":true,\"k4\":[{\"a\":\"b\",\"c\":\"d\"},{\"e\":\"f\",\"g\":\"h\"}]}";
+ assertEquals(StringUtil.trimJson(jsonString, 10), "{\"k1\":\"v1\",\"k2\":\"v2\"}");
+ assertEquals(StringUtil.trimJson(jsonString, 30), "{\"k1\":\"v1\",\"k2\":\"v2\",\"k3\":true}");
+ }
Review Comment:
I think we should verify whether the size of the trimmed JSON str oversized.
##########
oap-server/server-library/library-util/src/test/java/org/apache/skywalking/oap/server/library/util/StringUtilTest.java:
##########
@@ -76,4 +76,12 @@ public void testTrim() {
assertEquals(StringUtil.trim("abcdef", 'a'), "bcdef");
assertEquals(StringUtil.trim("abcdef", 'f'), "abcde");
}
+
+ @Test
+ public void testTrimJson() {
+ String jsonString = "{\"k1\":\"v1\",\"k2\":\"v2\",\"k3\":true,\"k4\":[{\"a\":\"b\",\"c\":\"d\"},{\"e\":\"f\",\"g\":\"h\"}]}";
+ assertEquals(StringUtil.trimJson(jsonString, 10), "{\"k1\":\"v1\",\"k2\":\"v2\"}");
+ assertEquals(StringUtil.trimJson(jsonString, 30), "{\"k1\":\"v1\",\"k2\":\"v2\",\"k3\":true}");
+ }
Review Comment:
I think we should verify whether the size of the trimmed JSON str is oversized.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org