Results 1 to 9 of 9

Thread: java.lang.NullPointerException during maximize

  1. #1
    Senior Member ckb's Avatar
    Join Date
    Mar 2006
    Posts
    941

    Default java.lang.NullPointerException during maximize

    Script execution aborted (java.lang.NullPointerException)

    This happened during a maximize. Re-running the script was successful, so I could not replicate it, though it has happened before. Posting debug log.
    Sorry there is not more info, but this is all I know.
    Attached Files

  2. #2
    Senior Member Crowther's Avatar
    Join Date
    Nov 2006
    Posts
    1,529

    Default

    I think I witnessed the same thing during a autoBasement managed basement dive. KoLmafia aborted during a maximize. Rerunning autoBasement should have run the same maximize function, but it did not abort until later. I was in a hurry and did not investigate more. I'm mentioning this because it might be a way to recreate this.

  3. #3
    Senior Member
    Join Date
    Apr 2009
    Posts
    1,866

    Default

    So ... something in inventory is (briefly) null? Weird.

  4. #4
    Senior Member
    Join Date
    Apr 2018
    Posts
    348

    Default

    The debug log seems to indicate the issue lies with Sweet Synthesis. I think it’s an off-by-one error when sorting candies?

  5. #5
    Senior Member
    Join Date
    Apr 2018
    Posts
    348

    Default

    Line 409 of CandyDatabase.java seems a likely culprit:
    Code:
    public int compareTo( final Candy o )
    {
        if ( o == null )
        {
            throw new NullPointerException();
        }
    
    
        return this.itemId - o.itemId;
    }

  6. #6
    Developer Veracity's Avatar
    Join Date
    Mar 2006
    Location
    The Unseelie Court
    Posts
    12,515

    Default

    According to the Java spec for compareTo, an NPE exception is the correct response to a null argument. So, not sure why that method is the “culprit”. Passing in a null object is the direct error. Having a null object when none is expected would be the real error.

  7. #7
    Senior Member
    Join Date
    Apr 2018
    Posts
    348

    Default

    According to the Java spec for compareTo, an NPE exception is the correct response to a null argument. So, not sure why that method is the “culprit”. Passing in a null object is the direct error. Having a null object when none is expected would be the real error.
    Originally Posted by Veracity View Post
    You’re right, that was a poor choice of words on my part. I meant that it is where the error is originating.

  8. #8
    Senior Member
    Join Date
    Apr 2009
    Posts
    1,866

    Default

    You’re right, that was a poor choice of words on my part. I meant that it is where the error is originating.
    Originally Posted by Saklad5 View Post
    That's where the error is *detected*. (the *exception* is originating there ..., but that's not that interesting).

  9. #9
    Developer
    Join Date
    Aug 2009
    Posts
    2,975

    Default

    Actually, a few frames up the stack trace is AdventureResult.getCount( inventory ), and inventory contains AdventureResults, so the Candy comparator shouldn't be relevant to this particular crash.

    The weird thing about xKiv's comment #3 (which is where I arrived as well) about something in inventory being null is that SortedListModel.add(int, E) explicitly refuses to add null elements. It's possible that somewhere is calling LockableListModel.set(null). I couldn't find any errors when I skimmed SortedListModel's binary search implementation, but that's also a possible culprit.

    (The only instance of inventory.set( index, result ) I could find is in AdventureResult.addResultToList(), but that looks to be adequately guarded against setting the value to null -- for one, indexOf would return -1 in that case, and we'd just call add().)

    (tangent: could we rip out the SortedListModels in favor of something more standard, like ConcurrentHashMaps if we actually need locking? I'm inclined to trust that said implementations have been much more heavily vetted by way of much wider industry adoption.)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •