ArrayIndexOutOfBoundsException in TLongObjectHashMap.rehash(..)

Issue #50 closed
Bartosz Firyn created an issue


At the very first words I would like to thank you for this great library :) It really helps me save a lot of Java heap space.

Now to the core of the problem. Today I noticed this exception in the logs:

Exception in thread "leaderboard-1" java.lang.ArrayIndexOutOfBoundsException: -26855
    at gnu.trove.impl.hash.THash.compact(
    at gnu.trove.impl.hash.THash.removeAt(
    at gnu.trove.impl.hash.TPrimitiveHash.removeAt(
    at gnu.trove.impl.hash.TLongHash.removeAt(
    at com.github.sarxos.elm.Leaderboard$

Please note that I experienced it only once, not really sure why, but regardless its rare occurence, I think it would be good to implement some check to verify if index of array is in bounds.

The code I invoke in is really simple, so I doubt it may be a cause of this problem:

private final TLongObjectHashMap<byte[]> bckref = new TLongObjectHashMap<>();


long id = score.getId().longValue();
if ((key = bckref.remove(id)) != null) {

The Trove version I'm using is:


Comments (9)

  1. Rob Eden

    I've never heard of this happening without being a threading issue. If you think otherwise, we'll need some more debugging info and possibly a test case.

  2. Bartosz Firyn reporter

    Hi. Well, it may be, at least in theory, since this reference should be accessed from by the single thread only (according to what I see in the code). I experienced this exception only once and the same code is working well for the very long time now.

  3. Rob Eden

    Nope, that shouldn't be the issue then. Dunno, sounds like threading to me. Could you try wrapping with TCollections.synchronizedMap(...) and see if that helps?

  4. jimdavies

    Without a test case demonstrating the issue, or some indication of under what circumstances it happens, I cannot proceed with a fix. I will re-open this when additional evidence is provided.

  5. Log in to comment