Infinite loop in java.util.HashMap

Is your background thread synchronized on the application instance when modifying the component? If not, then that is your problem.


Based on where it is in the code, the only explanation I can think of is that there are multiple threads accessing and updating that HashMap without synchronizing properly. This can cause the map's data structures to be corrupted, and could result in an infinite loop.

I can't think of any other reason why java.util.HashMap.getEntry would block. It doesn't do any synchronization or any I/O.


Roland Illig comments:

The line number indeed suggests that the code hangs in one of the e = e.next loops.

That supports my hypothesis. A particular sequence of operations on the hash table performed by two (or more) threads has resulted in the creation of a loop / cycle in one of the hash chains. This corruption has happened because there was inadequate synchronization between the threads performing the operations. It is the kind of thing that happens very rarely, but once it has happened the corruption won't go away.

Without looking deeply into the Vaadin source code, I can't tell you exactly whether it is a Vaadin bug, or a bug in the way that you are using Vaadin. Either explanation is plausible.

UPDATE

Based on this article (provided in a comment below), I would say that it is most likely a problem in the way that your application is synchronizing (or not).


So what you are actually seeing here is a thread going into an infinite loop evaluating e = e.next

In essence

e.next == e

This occurs when you are putting into a HashMap by multiple threads during a table restructure.

Take a look at this link for more information

A Beautiful Race Condition

To solve this either use a Collections.synchronizedMap or ConcurrentHashMap. I suggest the latter.