Skip to content

Commit 4e87631

Browse files
committed
Transaction finalizer should only complain about non-active transactions
1 parent 68d5ffc commit 4e87631

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

objectbox-java/src/main/java/io/objectbox/Transaction.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,9 @@ public Transaction(BoxStore store, long transaction, int initialCommitCount) {
7575

7676
@Override
7777
protected void finalize() throws Throwable {
78-
if (!closed) {
79-
System.err.println("Transaction was not closed (initial commit count: " + initialCommitCount + ").");
78+
// Committed & aborted transactions are fine: remaining native resources are not expensive
79+
if (!closed && nativeIsActive(transaction)) { // TODO what about recycled state?
80+
System.err.println("Transaction was not finished (initial commit count: " + initialCommitCount + ").");
8081
if (creationThrowable != null) {
8182
System.err.println("Transaction was initially created here:");
8283
creationThrowable.printStackTrace();

0 commit comments

Comments
 (0)