sszuev commented on code in PR #1994:
URL: https://github.com/apache/jena/pull/1994#discussion_r1308403762


##########
jena-core/src/main/java/org/apache/jena/graph/GraphMemFactory.java:
##########
@@ -30,8 +30,17 @@
 /**
  * A factory class for creating memory Graphs.
  * <p>
- * Apache Jena is migrating to term semantics graph for consistency across all 
in-memory and persistent storage graphs
- *
+ * Apache Jena is migrating to term semantics graph for consistency across all 
in-memory and persistent storage graphs.
+ * <p>
+ * All the graphs that this factory creates are <strong>not 
thread-safe</strong>.
+ * Note that if the memory Graph is structurally modified at any time after
+ * the iterator has been created by any of the {@code find*} or {@code 
stream*} methods, the iterator may throw
+ * a {@link java.util.ConcurrentModificationException 
ConcurrentModificationException}
+ * if continued with it after this modification.
+ * This may happen even if the queried data does not relate directly to 
modified data
+ * (i.e. when triple search pattern does not match added or deleted triple).
+ * The good practice is to explicitly close iterators immediately after a read 
operation or
+ * use terminate operations such as {@link ExtendedIterator#toList()}.

Review Comment:
   It looks like I still don't quite understand the functional difference 
between `ExtendedIterator` and `Stream`. 
   
   Both closeable, both have terminal and intrermediate operations (e.g. 
intermediate: `ExtendedIterator.filterKeep`, `Stream.filter`), both can be 
exhausted or not), both lazy. 
   What am I missing out on?
   
   The only functional difference I see - we can call `Iter.findFirst` several 
times, for `Stream.findFirst` it is not possible. But as I mention above, the 
method `ExternalIterator.findFirst` with close, would be more convenient than 
`Iter.findFirst` without close. Anyway this difference is not so important 
(IMO), maybe considered as a feature, which makes `ExtendedIterator` more 
suitable choice in some cases. And `Stream` is more heavy and complicated.
   
   `AutoCloseable` is not required to be closed, it is also "good practice", 
but in Java we can use `try-with-resources` to make our code safer more 
elegant. 
   Also, switching to `AutoCloseable` will not break user code.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to