- Notifications
You must be signed in to change notification settings - Fork124
Description
When aDbi
is created using a custom comparator it only works whilst a full GC has not run. This can be show by adding aSystem.gc()
between the construction of the map and theput
invocation inorg.lmdbjava.DbiTest#customComparator
.
On executingput
it throws:java.lang.NullPointerException: callable is null at jnr.ffi.provider.jffi.NativeClosureProxy.getCallable(NativeClosureProxy.java:57) at jnr.ffi.provider.jffi.NativeClosureProxy$$impl$$0.invoke(Unknown Source) at com.kenai.jffi.Foreign.invokeL5(Native Method) at com.kenai.jffi.Invoker.invokeL5(Invoker.java:438) at org.lmdbjava.Library$Lmdb$jnr$ffi$0.mdb_put(Unknown Source) at org.lmdbjava.Dbi.put(Dbi.java:421)
This happens sinceNativeClosureFactory.ClosureReference
is aWeakReference
and nothing else holds a reference to theComparatorCallback
.
I've tested that convertingComparatorCallback ccb
into a field fixes this, since it ensures the callback remains alive whilst theDbi
object is accessible.