@@ -131,7 +131,8 @@ public synchronized void close() {
131131 String threadType = isOwnerThread ? "owner thread" : "non-owner thread" ;
132132 if (readOnly ) {
133133 // Minor leak, but still print it so we can check logs: it should only happen occasionally.
134- // We cannot rely on the store waiting for read transactions; it only waits for a limited time.
134+ // Note that BoxStore.close() won't (briefly) wait on this transaction as isActive() already returns
135+ // false (and unregisterTransaction(this) was called) at this point.
135136 System .out .println ("Info: closing read transaction after store was closed (should be avoided) in " +
136137 threadType );
137138 System .out .flush ();
@@ -143,15 +144,19 @@ public synchronized void close() {
143144 // This is an internal validation: if this is a write-TX,
144145 // the (native) store will always wait for it, so it must not be destroyed yet.
145146 // If this ever happens, the above assumption is wrong, and it probably prevents a SIGSEGV.
146- throw new IllegalStateException (
147- "Cannot destroy write transaction for an already destroyed store" );
147+ // Note that BoxStore.close() won't (briefly) wait on this transaction as isActive() already
148+ // returns false (and unregisterTransaction(this) was called).
149+ throw new IllegalStateException ("Cannot close write transaction for an already closed store" );
148150 }
149151 nativeDestroy (transaction );
150152 }
151153 }
152154 }
153155 }
154156
157+ /**
158+ * For a write transaction commits the changes. For a read transaction throws.
159+ */
155160 public void commit () {
156161 checkOpen ();
157162 int [] entityTypeIdsAffected = nativeCommit (transaction );
@@ -163,6 +168,9 @@ public void commitAndClose() {
163168 close ();
164169 }
165170
171+ /**
172+ * For a read or write transaction, aborts it.
173+ */
166174 public void abort () {
167175 checkOpen ();
168176 nativeAbort (transaction );
@@ -214,6 +222,12 @@ public BoxStore getStore() {
214222 return store ;
215223 }
216224
225+ /**
226+ * A transaction is active after it was created until {@link #close()} or {@link #abort()} or for a write
227+ * transaction also until {@link #commit()} is called.
228+ *
229+ * @return If this transaction is active.
230+ */
217231 public boolean isActive () {
218232 return !closed && nativeIsActive (transaction );
219233 }
0 commit comments