提交 962ee3a4 编写于 作者: H henryjen

8029434: Spliterator of Stream returned by BufferedReader.lines() should have...

8029434: Spliterator of Stream returned by BufferedReader.lines() should have NONNULL characteristic
Reviewed-by: mduigou
上级 9bf9a7f6
......@@ -587,6 +587,7 @@ public class BufferedReader extends Reader {
}
}
};
return StreamSupport.stream(Spliterators.spliteratorUnknownSize(iter, Spliterator.ORDERED), false);
return StreamSupport.stream(Spliterators.spliteratorUnknownSize(
iter, Spliterator.ORDERED | Spliterator.NONNULL), false);
}
}
......@@ -23,7 +23,7 @@
/*
* @test
* @bug 8003258
* @bug 8003258 8029434
* @run testng Lines
*/
......@@ -38,6 +38,7 @@ import java.util.Map;
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 @@ public class Lines {
// 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.");
}
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册