Endless Loops In Unsychronized WeakHashMap 📎
java.util.WeakHashMap#get
:
public V get(Object key) {
Object k = maskNull(key);
int h = hash(k);
Entry[] tab = getTable();
int index = indexFor(h, tab.length);
Entry e = tab[index];
while (e != null) {
if (e.hash == h && eq(k, e.get()))
return e.value;
e = e.next;
}
return null;
}
Although it seems unlikely, it actually happens. One day we found a majority of worker threads stuck with the following stacktrace:
"httpSSLWorkerThread-32470-8"
java.lang.Thread.State: RUNNABLE
at java.util.WeakHashMap.get(WeakHashMap.java:355)
at javax.faces.component.UIComponentBase.populateDescriptorsMapIfNecessary(UIComponentBase.java:147)
at javax.faces.component.UIComponentBase.(UIComponentBase.java:142)
at javax.faces.component.UIOutput.(UIOutput.java:119)
See you at Java EE Workshops at MUC Airport (March 25th-28th)!