-
Bug
-
Resolution: Fixed
-
P3
-
11, 12, 13, 14
-
b27
A DESCRIPTION OF THE PROBLEM :
StringJoiner does not handle or detect when too large strings are joined or built. This can result in NegativeArraySizeException and possibly other incorrect behavior.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run the code provided below.
Requirements:
- String.COMPACT_STRINGS = true (probably the default)
- JVM arg -Xmx3G
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
RuntimeException or OutOfMemoryError is thrown during building because result would be too large.
ACTUAL -
NegativeArraySizeException is thrown.
---------- BEGIN SOURCE ----------
// To not get OutOfMemoryError because JVM cannot create that large arrays
int missingToMaxInt = 10;
// Requires String.COMPACT_STRINGS = true and -Xmx3G
new StringJoiner("")
.add("a".repeat(Integer.MAX_VALUE - missingToMaxInt))
.add("a".repeat(missingToMaxInt + 1))
.toString();
---------- END SOURCE ----------
StringJoiner does not handle or detect when too large strings are joined or built. This can result in NegativeArraySizeException and possibly other incorrect behavior.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run the code provided below.
Requirements:
- String.COMPACT_STRINGS = true (probably the default)
- JVM arg -Xmx3G
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
RuntimeException or OutOfMemoryError is thrown during building because result would be too large.
ACTUAL -
NegativeArraySizeException is thrown.
---------- BEGIN SOURCE ----------
// To not get OutOfMemoryError because JVM cannot create that large arrays
int missingToMaxInt = 10;
// Requires String.COMPACT_STRINGS = true and -Xmx3G
new StringJoiner("")
.add("a".repeat(Integer.MAX_VALUE - missingToMaxInt))
.add("a".repeat(missingToMaxInt + 1))
.toString();
---------- END SOURCE ----------
- relates to
-
JDK-8230744 Several classes throw OutOfMemoryError without message
- Resolved