changeset 8940:6d583b9d99e1

8029434: Spliterator of Stream returned by BufferedReader.lines() should have NONNULL characteristic Reviewed-by: mduigou
author henryjen
date Wed, 04 Dec 2013 08:12:11 -0800
parents e984e2871bf7
children 0f1332dd805c
files src/share/classes/java/io/BufferedReader.java test/java/io/BufferedReader/Lines.java
diffstat 2 files changed, 15 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/java/io/BufferedReader.java	Wed Dec 04 11:04:05 2013 +0100
+++ b/src/share/classes/java/io/BufferedReader.java	Wed Dec 04 08:12:11 2013 -0800
@@ -587,6 +587,7 @@
                 }
             }
         };
-        return StreamSupport.stream(Spliterators.spliteratorUnknownSize(iter, Spliterator.ORDERED), false);
+        return StreamSupport.stream(Spliterators.spliteratorUnknownSize(
+                iter, Spliterator.ORDERED | Spliterator.NONNULL), false);
     }
 }
--- a/test/java/io/BufferedReader/Lines.java	Wed Dec 04 11:04:05 2013 +0100
+++ b/test/java/io/BufferedReader/Lines.java	Wed Dec 04 08:12:11 2013 -0800
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @bug 8003258
+ * @bug 8003258 8029434
  * @run testng Lines
  */
 
@@ -38,6 +38,7 @@
 import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.NoSuchElementException;
+import java.util.Spliterator;
 import java.util.stream.Stream;
 import java.util.concurrent.atomic.AtomicInteger;
 import org.testng.annotations.Test;
@@ -281,4 +282,15 @@
         // Read after EOL
         assertFalse(it.hasNext());
     }
+
+    public void testCharacteristics() {
+        try (BufferedReader br = new BufferedReader(
+                                    new StringReader(""))) {
+            Spliterator<String> instance = br.lines().spliterator();
+            assertTrue(instance.hasCharacteristics(Spliterator.NONNULL));
+            assertTrue(instance.hasCharacteristics(Spliterator.ORDERED));
+        } catch (IOException ioe) {
+            fail("Should not have any exception.");
+        }
+    }
 }