So here I have a really strange mistake on my treemap that happen from time to time.
There she is :
java.lang.NullPointerException
At java.util.TreeMap.rotateRight (TreeMap.java:2243)
At java.util.TreeMap.fixAfterInsertion (TreeMap.java:2275)
At java.util.TreeMap.put (TreeMap.java:582)
The error is made an addition of an object in a map therefore.
I understand that this was a very rare case since it is actually two threads that start at the same time to do the same action. A check to avoid duplicates is done and the error is well on the put, so that's why I think that's the worry. Would a sync on this map solve the worry? While knowing that there are instructions in strings: We load characters, we load the items. If we have a worry about the load of the items, it is that there is a double load of the character simultaneously.
So I would like your opinion on that and above all, would you have an idea how to solve the problem? Knowing that the method "I try then we see what it gives to the compilation" can not work because I can reproduce the bug at my will.
Thank you in advance if you get to help me, or else you try at least :)