IllegalArgumentException: Equal objects must have equal hashcodes

Issue #24 invalid
Tobo created an issue

No description provided.

Comments (10)

  1. Rob Eden

    This error happens when the result of the equals() method changes but the hashCode() does not, or vice versa. This is likely to be a problem with your key objects rather than a bug in Trove.

    From one of the lines in your code, I assume you are pre-calculating your hashCode() values. Could it be that the data being checked in equals() change such that its result changed but equals() was cached? On those lines, you could probably also hit this if the key objects were being modified (in ways that would change equals() & hashCode()) while in the map.

    So, things to check:

    1. Make sure equals() & hashCode() are always in lock step.
    2. Make sure your key objects aren't being modified while in the map.

    If nothing stands out as a problem, perhaps your could attach your keys objects, or at least the equals()/hashCode() methods?

  2. Tobo reporter

    hm you may be right , do you have any hints how to fix this code-wise. I am a bit unsure. I get what you are saying but ye.

  3. Rob Eden

    The best way is to keep your keys immutable. That way you know the data isn't changing out from under them. Then it's just a matter of putting the equals/hashCode methods together correctly. (If you use an IDE like IntelliJ IDEA, it can generate them for you, which I find to be the easiest route.)

    If your key has to be mutable, make sure it doesn't change (in a way that would change equals/hashCode) while in the map.

    A quick Google search tells me this is part of L2j Server? If so and you can't figure out what's wrong, I can try to take a look at the class and see if I have any advice.

  4. Tobo reporter

    Rob, alright thanks for the hints. It is and it is not part of l2j we derived from l2j long time ago so our code is very different (and imo more efficient in many places). We are having issues on how to solves this properly and are thinking that those errors above appeared due to DDOS on one of ours servers. However I would be glad if you still could have a look maybe you have some insight on how to solve it. Let me know if I can provide something to help me solved it ;)

  5. Tobo reporter

    Anyway I think you can close this for now. We talked about it and came to insight it was most likely a huge ddos attack that crashed our server which caused them to mutate somehow. So this can be set to invalid, sorry for wasting your time.

  6. Rob Eden

    If the code is publicly available or if you want to send me relevant classes, I'd be happy to take a look and give any advice I can. My email is: robeden1 gmail dot com

  7. Log in to comment