You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Fred Hauschel <in...@hauschel.de> on 2025/04/17 16:18:15 UTC
[RDF] ModelGraphImpl returns 'parallelStream()' instead of expected 'stream()'
Hi there, in my opinion this is a bug:
* https://github.com/apache/commons-rdf/blob/006fbc3e47003c2d0fe8eb055f60f7cb267e1321/commons-rdf-rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/impl/ModelGraphImpl.java#L142
* https://github.com/apache/commons-rdf/blob/006fbc3e47003c2d0fe8eb055f60f7cb267e1321/commons-rdf-rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/impl/ModelGraphImpl.java#L150
Because nobody expects a parallel stream to be created and returned when
stream() is called.
There is also a great danger that this parallel stream will be used to
perform write operations with RDF4J. However, RDF4J is not thread-safe
and this can lead to non-deterministic results.
What is your opinion on this?
Thanks Fredy
Re: [RDF] ModelGraphImpl returns 'parallelStream()' instead of expected 'stream()'
Posted by Gary Gregory <ga...@gmail.com>.
On Thu, Apr 17, 2025 at 12:18 PM Fred Hauschel <in...@hauschel.de> wrote:
>
> Hi there, in my opinion this is a bug:
>
> * https://github.com/apache/commons-rdf/blob/006fbc3e47003c2d0fe8eb055f60f7cb267e1321/commons-rdf-rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/impl/ModelGraphImpl.java#L142
> * https://github.com/apache/commons-rdf/blob/006fbc3e47003c2d0fe8eb055f60f7cb267e1321/commons-rdf-rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/impl/ModelGraphImpl.java#L150
>
> Because nobody expects a parallel stream to be created and returned when
> stream() is called.
> There is also a great danger that this parallel stream will be used to
> perform write operations with RDF4J. However, RDF4J is not thread-safe
> and this can lead to non-deterministic results.
>
> What is your opinion on this?
Hello Fredy,
At first glance, I would say that a Java stream() implementation that
internally calls parallelStream() seems questionable unless explicitly
documented.
Let's wait and see if Stian Soiland-Reyes replies to this thread since
he authored at least one of these methods.
TY,
Gary
>
> Thanks Fredy
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org