8029434: Spliterator of Stream returned by BufferedReader.lines() should have NONNULL characteristic
Reviewed-by: mduigou
This commit is contained in:
parent
6c53570dc7
commit
40d9b1af54
@ -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.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user