You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to learn java and i found your article very interesting and useful, able to solve in a clear and simple way what seems to me a deficiency in the current implementation of java.
By trying to use the library I noticed that the characteristics of ResultCollector were not specified.
public Set<Characteristics> characteristics() { return Set.of(); }
So I tried to verify its behavior with a parallel stream and I noticed a wrong result.
@TestvoidcollectorSyncronization() {
Supplier<Integer> fn = () -> newRandom().nextInt(10);
// ok this is std collectorassertDoesNotThrow(() -> Stream.generate(fn).parallel().limit(100).collect(Collectors.toList()));
// trying the same with a CheckedSupplier and a ResultSupplier<Result<Integer,Exception>> randomNumbersSupp=() -> Result.attempt(() -> fn.get());
Stream<Result<Integer,Exception>> streamOfValues = Stream.generate(randomNumbersSupp)
.limit(100);
// with a serial stream all is okList<Integer> values = assertDoesNotThrow( () ->
streamOfValues
.collect(newResultCollector<>())
.getValue().get()
);
// with a parallelStream something go wrong assertThrows( Exception.class, () ->
streamOfValues
.parallel()
.collect(newResultCollector<>())
.getValue().get()
);
}
The text was updated successfully, but these errors were encountered:
hi,
I'm trying to learn java and i found your article very interesting and useful, able to solve in a clear and simple way what seems to me a deficiency in the current implementation of java.
By trying to use the library I noticed that the characteristics of
ResultCollector
were not specified.public Set<Characteristics> characteristics() { return Set.of(); }
So I tried to verify its behavior with a parallel stream and I noticed a wrong result.
The text was updated successfully, but these errors were encountered: