Details
-
Bug
-
Resolution: Fixed
-
P4
-
8, 9
-
b34
-
generic
-
generic
-
Not verified
Description
FULL PRODUCT VERSION :
ADDITIONAL OS VERSION INFORMATION :
MacOS Sierra
A DESCRIPTION OF THE PROBLEM :
Below is the code, if you uncomment Stream.concat then you will see that stream supplier has been called, but it should not happen because concat is not a terminal operation
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Try the code fragment
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Stream.concat should behave as intermediate operation, stream supplier should not be called
ACTUAL -
I see that both streams are being initialized even without stream usage
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
@Test
public void testConcat() {
Stream<Integer> stream = createLazyStream();
// Stream<Integer> result = Stream.concat(stream, createLazyStream());
}
private Stream<Integer> createLazyStream() {
return StreamSupport.stream(() -> {
System.out.println("initializing stream");
return IntStream.range(1,10).spliterator();
}, Spliterator.ORDERED, false);
}
---------- END SOURCE ----------
ADDITIONAL OS VERSION INFORMATION :
MacOS Sierra
A DESCRIPTION OF THE PROBLEM :
Below is the code, if you uncomment Stream.concat then you will see that stream supplier has been called, but it should not happen because concat is not a terminal operation
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Try the code fragment
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Stream.concat should behave as intermediate operation, stream supplier should not be called
ACTUAL -
I see that both streams are being initialized even without stream usage
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
@Test
public void testConcat() {
Stream<Integer> stream = createLazyStream();
// Stream<Integer> result = Stream.concat(stream, createLazyStream());
}
private Stream<Integer> createLazyStream() {
return StreamSupport.stream(() -> {
System.out.println("initializing stream");
return IntStream.range(1,10).spliterator();
}, Spliterator.ORDERED, false);
}
---------- END SOURCE ----------
Attachments
Issue Links
- csr for
-
JDK-8191939 Stream.concat behaves like terminal operation
-
- Closed
-