File tree Expand file tree Collapse file tree 1 file changed +6
-6
lines changed
objectbox-java/src/main/java/io/objectbox Expand file tree Collapse file tree 1 file changed +6
-6
lines changed Original file line number Diff line number Diff line change @@ -233,7 +233,7 @@ public static boolean isSyncServerAvailable() {
233
233
private final File directory ;
234
234
private final String canonicalPath ;
235
235
/** Reference to the native store. Should probably get through {@link #getNativeStore()} instead. */
236
- private long handle ;
236
+ volatile private long handle ;
237
237
private final Map <Class <?>, String > dbNameByClass = new HashMap <>();
238
238
private final Map <Class <?>, Integer > entityTypeIdByClass = new HashMap <>();
239
239
private final Map <Class <?>, EntityInfo <?>> propertiesByClass = new HashMap <>();
@@ -690,11 +690,11 @@ public void close() {
690
690
t .close ();
691
691
}
692
692
693
- if ( handle != 0 ) { // failed before native handle was created?
694
- nativeDelete ( handle );
695
- // The Java API has open checks, but just in case re-set the handle so any native methods will
696
- // not crash due to an invalid pointer.
697
- handle = 0 ;
693
+ long handleToDelete = handle ;
694
+ // Make isNativeStoreClosed() return true before actually closing to avoid Transaction.close() crash
695
+ handle = 0 ;
696
+ if ( handleToDelete != 0 ) { // failed before native handle was created?
697
+ nativeDelete ( handleToDelete ) ;
698
698
}
699
699
700
700
// When running the full unit test suite, we had 100+ threads before, hope this helps:
You can’t perform that action at this time.
0 commit comments