RFR: 8230743 - StringJoiner does not handle too large strings correctly
Paul Sandoz
paul.sandoz at oracle.com
Mon Jun 1 19:28:23 UTC 2020
Can we consolidate the use of Integer.MAX_VALUE - 8 in tests by referring to the constant jdk.internal.util.ArraysSupport.MAX_ARRAY_LENGTH?
StringJoiner.java
—
164 @Override
165 public String toString() {
166 final String[] elts = this.elts;
167 if (elts == null && emptyValue != null) {
168 return emptyValue;
169 }
170 final int size = this.size;
171 final int addLen = prefix.length() + suffix.length();
172 if (len < 0 || len + addLen < 0) {
It bothers me that len might be < 0, suggesting a larger issue. Perhaps look at the add method where len is modified?
173 throw new
174 OutOfMemoryError("Resulting string is exceeds maximum size”);
"Resulting string is exceeds… ” -> "Resulting string exceeds… "
Paul.
> On Jun 1, 2020, at 8:55 AM, Jim Laskey <james.laskey at oracle.com> wrote:
>
> Change NegativeArraySizeException to OutOfMemoryError. Tests added.
>
> Cheers,
>
> -- Jim
>
> webrev: http://cr.openjdk.java.net/~jlaskey/8230743/webrev-00/index.html <http://cr.openjdk.java.net/~jlaskey/8230743/webrev-00/index.html>
> jbs: https://bugs.openjdk.java.net/browse/JDK-8230743 <https://bugs.openjdk.java.net/browse/JDK-8230743>
>
More information about the core-libs-dev
mailing list