8029434: Spliterator of Stream returned by BufferedReader.lines() should have NONNULL characteristic
authorhenryjen
Wed, 04 Dec 2013 08:12:11 -0800
changeset 21971 284411f25f79
parent 21970 fb9a728c4b77
child 21972 c2c358652884
8029434: Spliterator of Stream returned by BufferedReader.lines() should have NONNULL characteristic Reviewed-by: mduigou
jdk/src/share/classes/java/io/BufferedReader.java
jdk/test/java/io/BufferedReader/Lines.java
--- a/jdk/src/share/classes/java/io/BufferedReader.java	Wed Dec 04 11:04:05 2013 +0100
+++ b/jdk/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/jdk/test/java/io/BufferedReader/Lines.java	Wed Dec 04 11:04:05 2013 +0100
+++ b/jdk/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.");
+        }
+    }
 }