8017141: java.util/stream Spliterators from sequential sources should not catch OOME
authorhenryjen
Tue, 09 Jul 2013 09:15:57 +0200
changeset 18788 1bfd5f623662
parent 18787 8a57ff107238
child 18789 b518cd4045bc
8017141: java.util/stream Spliterators from sequential sources should not catch OOME Reviewed-by: mchung Contributed-by: paul.sandoz@oracle.com
jdk/src/share/classes/java/util/LinkedList.java
jdk/src/share/classes/java/util/Spliterators.java
--- a/jdk/src/share/classes/java/util/LinkedList.java	Mon Jul 08 22:43:36 2013 -0700
+++ b/jdk/src/share/classes/java/util/LinkedList.java	Tue Jul 09 09:15:57 2013 +0200
@@ -1195,12 +1195,7 @@
                     n = s;
                 if (n > MAX_BATCH)
                     n = MAX_BATCH;
-                Object[] a;
-                try {
-                    a = new Object[n];
-                } catch (OutOfMemoryError oome) {
-                    return null;
-                }
+                Object[] a = new Object[n];
                 int j = 0;
                 do { a[j++] = p.item; } while ((p = p.next) != null && j < n);
                 current = p;
--- a/jdk/src/share/classes/java/util/Spliterators.java	Mon Jul 08 22:43:36 2013 -0700
+++ b/jdk/src/share/classes/java/util/Spliterators.java	Tue Jul 09 09:15:57 2013 +0200
@@ -1314,12 +1314,7 @@
                     n = (int) s;
                 if (n > MAX_BATCH)
                     n = MAX_BATCH;
-                Object[] a;
-                try {
-                    a = new Object[n];
-                } catch (OutOfMemoryError oome) {
-                    return null;
-                }
+                Object[] a = new Object[n];
                 int j = 0;
                 do { a[j] = holder.value; } while (++j < n && tryAdvance(holder));
                 batch = j;
@@ -1429,12 +1424,7 @@
                     n = (int) s;
                 if (n > MAX_BATCH)
                     n = MAX_BATCH;
-                int[] a;
-                try {
-                    a = new int[n];
-                } catch (OutOfMemoryError oome) {
-                    return null;
-                }
+                int[] a = new int[n];
                 int j = 0;
                 do { a[j] = holder.value; } while (++j < n && tryAdvance(holder));
                 batch = j;
@@ -1544,12 +1534,7 @@
                     n = (int) s;
                 if (n > MAX_BATCH)
                     n = MAX_BATCH;
-                long[] a;
-                try {
-                    a = new long[n];
-                } catch (OutOfMemoryError oome) {
-                    return null;
-                }
+                long[] a = new long[n];
                 int j = 0;
                 do { a[j] = holder.value; } while (++j < n && tryAdvance(holder));
                 batch = j;
@@ -1659,12 +1644,7 @@
                     n = (int) s;
                 if (n > MAX_BATCH)
                     n = MAX_BATCH;
-                double[] a;
-                try {
-                    a = new double[n];
-                } catch (OutOfMemoryError oome) {
-                    return null;
-                }
+                double[] a = new double[n];
                 int j = 0;
                 do { a[j] = holder.value; } while (++j < n && tryAdvance(holder));
                 batch = j;
@@ -1795,12 +1775,7 @@
                     n = (int) s;
                 if (n > MAX_BATCH)
                     n = MAX_BATCH;
-                Object[] a;
-                try {
-                    a = new Object[n];
-                } catch (OutOfMemoryError oome) {
-                    return null;
-                }
+                Object[] a = new Object[n];
                 int j = 0;
                 do { a[j] = i.next(); } while (++j < n && i.hasNext());
                 batch = j;
@@ -1910,12 +1885,7 @@
                     n = (int) s;
                 if (n > MAX_BATCH)
                     n = MAX_BATCH;
-                int[] a;
-                try {
-                    a = new int[n];
-                } catch (OutOfMemoryError oome) {
-                    return null;
-                }
+                int[] a = new int[n];
                 int j = 0;
                 do { a[j] = i.nextInt(); } while (++j < n && i.hasNext());
                 batch = j;
@@ -2007,12 +1977,7 @@
                     n = (int) s;
                 if (n > MAX_BATCH)
                     n = MAX_BATCH;
-                long[] a;
-                try {
-                    a = new long[n];
-                } catch (OutOfMemoryError oome) {
-                    return null;
-                }
+                long[] a = new long[n];
                 int j = 0;
                 do { a[j] = i.nextLong(); } while (++j < n && i.hasNext());
                 batch = j;
@@ -2104,12 +2069,7 @@
                     n = (int) s;
                 if (n > MAX_BATCH)
                     n = MAX_BATCH;
-                double[] a;
-                try {
-                    a = new double[n];
-                } catch (OutOfMemoryError oome) {
-                    return null;
-                }
+                double[] a = new double[n];
                 int j = 0;
                 do { a[j] = i.nextDouble(); } while (++j < n && i.hasNext());
                 batch = j;