Skip to content

Commit 53d5def

Browse files
Sunder90claude
andcommitted
java: replace String.repeat() with StringBuilder for Java 8 compat
String.repeat() was added in Java 11. Use a StringBuilder loop instead to maintain Java 8 compatibility per project requirements. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 501ff71 commit 53d5def

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

java/util/src/test/java/com/google/protobuf/util/JsonFormatTest.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -792,7 +792,9 @@ public void testParserRejectOutOfRangeNumericValues() throws Exception {
792792
public void testParserRejectOverlyLongNumericStrings() throws Exception {
793793
// A numeric string with 10,000 digits should be rejected quickly to prevent
794794
// O(N^2) BigDecimal parsing DoS.
795-
String longNumber = "1" + "0".repeat(10000);
795+
StringBuilder sb = new StringBuilder("1");
796+
for (int i = 0; i < 10000; i++) sb.append('0');
797+
String longNumber = sb.toString();
796798
String[] fields = {
797799
"optionalInt32", "optionalInt64", "optionalUint32", "optionalUint64", "optionalDouble"
798800
};

0 commit comments

Comments
 (0)