You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When a Dbi is created using a custom comparator it only works whilst a full GC has not run. This can be show by adding a System.gc() between the construction of the map and the put invocation in org.lmdbjava.DbiTest#customComparator.
On executing put 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 since NativeClosureFactory.ClosureReference is a WeakReference and nothing else holds a reference to theComparatorCallback.
I've tested that converting ComparatorCallback ccb into a field fixes this, since it ensures the callback remains alive whilst the Dbi object is accessible.
When a
Dbiis 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 theputinvocation inorg.lmdbjava.DbiTest#customComparator.On executing
putit 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 since
NativeClosureFactory.ClosureReferenceis aWeakReferenceand nothing else holds a reference to theComparatorCallback.I've tested that converting
ComparatorCallback ccbinto a field fixes this, since it ensures the callback remains alive whilst theDbiobject is accessible.