Github user ajs6f commented on a diff in the pull request:
https://github.com/apache/jena/pull/154#discussion_r70663415
--- Diff:
jena-tdb/src/main/java/org/apache/jena/tdb/transaction/TransactionManager.java
---
@@ -436,8 +469,96 @@ public void notifyAbort(Transaction transaction)
switch ( transaction.getMode() )
{
case READ: break ;
- case WRITE: writersWaiting.release() ;
+ case WRITE: releaseWriterLock();
+ }
+ }
+
+ private void releaseWriterLock() {
+ int x = writersWaiting.availablePermits() ;
+ if ( x != 0 )
+ throw new TDBTransactionException("TransactionCoordinator:
Probably mismatch of enable/disableWriter calls") ;
+ writersWaiting.release() ;
+ }
+
+ private boolean acquireWriterLock(boolean canBlock) {
+ if ( ! canBlock )
+ return writersWaiting.tryAcquire() ;
+ try {
+ writersWaiting.acquire() ;
+ return true;
+ } catch (InterruptedException e) { throw new
TDBTransactionException(e) ; }
+ }
+
+ /** Block until no writers are active.
--- End diff --
Just a "wordsmithing" suggestion: this might be better as `waitForWriters`
or the like. `disableWriters` sounds a bit like the caller is going to have
some kind of actual impact on the outstanding writers, but in truth the caller
is just waiting for them to finish on their own, right? Same for the next
method.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---