Skip to content

Commit 6bf03a0

Browse files
committed
Add missing null-check when closing an Arena
1 parent 3be82c6 commit 6bf03a0

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

  • modules/glib/src/main/java/org/javagi/interop

modules/glib/src/main/java/org/javagi/interop/Arenas.java

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,14 @@ public static void close_cb(MemorySegment data) {
8484

8585
int hashCode = data.reinterpret(ValueLayout.JAVA_INT.byteSize())
8686
.get(ValueLayout.JAVA_INT, 0);
87-
ARENAS.get(hashCode).thenAccept(arena -> {
88-
ARENAS.remove(hashCode);
89-
if (arena != null)
90-
arena.close();
91-
});
87+
var future = ARENAS.get(hashCode);
88+
if (future != null) {
89+
future.thenAccept(arena -> {
90+
ARENAS.remove(hashCode);
91+
if (arena != null)
92+
arena.close();
93+
});
94+
}
9295
}
9396

9497
/**

0 commit comments

Comments
 (0)