GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Using Custom Comparator throws NullPointerException after GC · Issue #125 · lmdbjava/lmdbjava

Using Custom Comparator throws NullPointerException after GC #125

New issue
Copy link
New issue
Copy link
Closed
Closed
Using Custom Comparator throws NullPointerException after GC#125
Copy link
Labels
bugAn issue relates to behaviour that violates the intention of the libraryAn issue relates to behaviour that violates the intention of the library

Description

@jheister
jheister
opened on Apr 6, 2019
Issue body actions

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.

Activity

  1. bp-alex
    added
    bugAn issue relates to behaviour that violates the intention of the libraryAn issue relates to behaviour that violates the intention of the library
    on Apr 9, 2019
  2. bp-alex commented on Apr 9, 2019

    @bp-alex
    bp-alex
    on Apr 9, 2019
    Member
    More actions

    Thanks for such a well-described issue report. I was able to reproduce it locally, but didn't add the System.gc() to the test because it causes PMD and Spotbugs to object.

    Reacted by Justin Heister
  3. bp-alex
    closed this as completedin 5912bebon Apr 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugAn issue relates to behaviour that violates the intention of the libraryAn issue relates to behaviour that violates the intention of the library

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402503 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.