8017141: java.util/stream Spliterators from sequential sources should not catch OOME
Reviewed-by: mchung
This commit is contained in:
parent
0fb5272229
commit
2409f0944c
@ -1195,12 +1195,7 @@ public class LinkedList<E>
|
|||||||
n = s;
|
n = s;
|
||||||
if (n > MAX_BATCH)
|
if (n > MAX_BATCH)
|
||||||
n = MAX_BATCH;
|
n = MAX_BATCH;
|
||||||
Object[] a;
|
Object[] a = new Object[n];
|
||||||
try {
|
|
||||||
a = new Object[n];
|
|
||||||
} catch (OutOfMemoryError oome) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
int j = 0;
|
int j = 0;
|
||||||
do { a[j++] = p.item; } while ((p = p.next) != null && j < n);
|
do { a[j++] = p.item; } while ((p = p.next) != null && j < n);
|
||||||
current = p;
|
current = p;
|
||||||
|
@ -1314,12 +1314,7 @@ public final class Spliterators {
|
|||||||
n = (int) s;
|
n = (int) s;
|
||||||
if (n > MAX_BATCH)
|
if (n > MAX_BATCH)
|
||||||
n = MAX_BATCH;
|
n = MAX_BATCH;
|
||||||
Object[] a;
|
Object[] a = new Object[n];
|
||||||
try {
|
|
||||||
a = new Object[n];
|
|
||||||
} catch (OutOfMemoryError oome) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
int j = 0;
|
int j = 0;
|
||||||
do { a[j] = holder.value; } while (++j < n && tryAdvance(holder));
|
do { a[j] = holder.value; } while (++j < n && tryAdvance(holder));
|
||||||
batch = j;
|
batch = j;
|
||||||
@ -1429,12 +1424,7 @@ public final class Spliterators {
|
|||||||
n = (int) s;
|
n = (int) s;
|
||||||
if (n > MAX_BATCH)
|
if (n > MAX_BATCH)
|
||||||
n = MAX_BATCH;
|
n = MAX_BATCH;
|
||||||
int[] a;
|
int[] a = new int[n];
|
||||||
try {
|
|
||||||
a = new int[n];
|
|
||||||
} catch (OutOfMemoryError oome) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
int j = 0;
|
int j = 0;
|
||||||
do { a[j] = holder.value; } while (++j < n && tryAdvance(holder));
|
do { a[j] = holder.value; } while (++j < n && tryAdvance(holder));
|
||||||
batch = j;
|
batch = j;
|
||||||
@ -1544,12 +1534,7 @@ public final class Spliterators {
|
|||||||
n = (int) s;
|
n = (int) s;
|
||||||
if (n > MAX_BATCH)
|
if (n > MAX_BATCH)
|
||||||
n = MAX_BATCH;
|
n = MAX_BATCH;
|
||||||
long[] a;
|
long[] a = new long[n];
|
||||||
try {
|
|
||||||
a = new long[n];
|
|
||||||
} catch (OutOfMemoryError oome) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
int j = 0;
|
int j = 0;
|
||||||
do { a[j] = holder.value; } while (++j < n && tryAdvance(holder));
|
do { a[j] = holder.value; } while (++j < n && tryAdvance(holder));
|
||||||
batch = j;
|
batch = j;
|
||||||
@ -1659,12 +1644,7 @@ public final class Spliterators {
|
|||||||
n = (int) s;
|
n = (int) s;
|
||||||
if (n > MAX_BATCH)
|
if (n > MAX_BATCH)
|
||||||
n = MAX_BATCH;
|
n = MAX_BATCH;
|
||||||
double[] a;
|
double[] a = new double[n];
|
||||||
try {
|
|
||||||
a = new double[n];
|
|
||||||
} catch (OutOfMemoryError oome) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
int j = 0;
|
int j = 0;
|
||||||
do { a[j] = holder.value; } while (++j < n && tryAdvance(holder));
|
do { a[j] = holder.value; } while (++j < n && tryAdvance(holder));
|
||||||
batch = j;
|
batch = j;
|
||||||
@ -1795,12 +1775,7 @@ public final class Spliterators {
|
|||||||
n = (int) s;
|
n = (int) s;
|
||||||
if (n > MAX_BATCH)
|
if (n > MAX_BATCH)
|
||||||
n = MAX_BATCH;
|
n = MAX_BATCH;
|
||||||
Object[] a;
|
Object[] a = new Object[n];
|
||||||
try {
|
|
||||||
a = new Object[n];
|
|
||||||
} catch (OutOfMemoryError oome) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
int j = 0;
|
int j = 0;
|
||||||
do { a[j] = i.next(); } while (++j < n && i.hasNext());
|
do { a[j] = i.next(); } while (++j < n && i.hasNext());
|
||||||
batch = j;
|
batch = j;
|
||||||
@ -1910,12 +1885,7 @@ public final class Spliterators {
|
|||||||
n = (int) s;
|
n = (int) s;
|
||||||
if (n > MAX_BATCH)
|
if (n > MAX_BATCH)
|
||||||
n = MAX_BATCH;
|
n = MAX_BATCH;
|
||||||
int[] a;
|
int[] a = new int[n];
|
||||||
try {
|
|
||||||
a = new int[n];
|
|
||||||
} catch (OutOfMemoryError oome) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
int j = 0;
|
int j = 0;
|
||||||
do { a[j] = i.nextInt(); } while (++j < n && i.hasNext());
|
do { a[j] = i.nextInt(); } while (++j < n && i.hasNext());
|
||||||
batch = j;
|
batch = j;
|
||||||
@ -2007,12 +1977,7 @@ public final class Spliterators {
|
|||||||
n = (int) s;
|
n = (int) s;
|
||||||
if (n > MAX_BATCH)
|
if (n > MAX_BATCH)
|
||||||
n = MAX_BATCH;
|
n = MAX_BATCH;
|
||||||
long[] a;
|
long[] a = new long[n];
|
||||||
try {
|
|
||||||
a = new long[n];
|
|
||||||
} catch (OutOfMemoryError oome) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
int j = 0;
|
int j = 0;
|
||||||
do { a[j] = i.nextLong(); } while (++j < n && i.hasNext());
|
do { a[j] = i.nextLong(); } while (++j < n && i.hasNext());
|
||||||
batch = j;
|
batch = j;
|
||||||
@ -2104,12 +2069,7 @@ public final class Spliterators {
|
|||||||
n = (int) s;
|
n = (int) s;
|
||||||
if (n > MAX_BATCH)
|
if (n > MAX_BATCH)
|
||||||
n = MAX_BATCH;
|
n = MAX_BATCH;
|
||||||
double[] a;
|
double[] a = new double[n];
|
||||||
try {
|
|
||||||
a = new double[n];
|
|
||||||
} catch (OutOfMemoryError oome) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
int j = 0;
|
int j = 0;
|
||||||
do { a[j] = i.nextDouble(); } while (++j < n && i.hasNext());
|
do { a[j] = i.nextDouble(); } while (++j < n && i.hasNext());
|
||||||
batch = j;
|
batch = j;
|
||||||
|
Loading…
Reference in New Issue
Block a user