sszuev commented on issue #2195:
URL: https://github.com/apache/jena/issues/2195#issuecomment-1891974098
> `GraphTxn` is intended to provide auto-commit style semantics for
`Graph`'s. However there was a bug in the `GraphTxn` implementation in the
4.10.0 release (#2086) where it incorrectly determined the current transaction
state and wasn't always creating a transaction when necessary (and conversely
would try to incorrectly create a transaction when unnecessary)
>
> So the behaviour you are seeing with 5.0.0-SNAPSHOT is the correct
expected behaviour
>
> Creating the iterator starts a read transaction that isn't committed until
you explicitly `close()` the iterator. Trying to do a `g.add()` tries to start
a write transaction but it can't because the read transaction is still in
progress.
>
> If you plan to use `GraphTxn` seriously then you should explicitly manage
the transactions to get the transaction boundaries appropriate to your
application.
additional note about the original issue. the following test also works in <
5.0.0-SNAPSHOT.
So, the easiest fix to add `close` in terminal operations (such as `toList`)
won't help.
```
Node x = NodeFactory.createURI("X");
Node q = NodeFactory.createURI("Q");
GraphTxn g = new GraphTxn();
g.add(Triple.create(x, q, q));
ExtendedIterator<Triple> it = g.find(Triple.create(x, Node.ANY, Node.ANY));
it.next();
g.add(Triple.create(q, q, x));
```
--
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]