Search code examples
javamultithreadinghashmapthread-safety

How can I programatically recreate these WebSphere logs due to unsynchronized access to HashMap?


We have few components in our project extending HashMap. Due to unsynchronized access to the HashMap object we are getting the logs like the below one in production:

ThreadMonitor W WSVR0605W:Thread "webcontainer:5" has been active for 864096 milliseconds and may be hung.There is/are 5 thread(s) in the total server that may be hung.
    at java.util.HashMap.findNonNullKeyEntry(HashMap.java:525)
    at java.util.HashMap.putImpl(HashMap.java:622)
    at java.util.HashMap.put(HashMap.java:605

I want to recreate this for the testing purpose and tried spawning different threads putting and getting the HashMap object, but still no breakthroughs. Also, I have set loadFactor to 0.1 so that resizing of the HashMap will occur more frequently, which we are analysing is causing the issue (structural changes in the HahMap).

We are using IBM Java version 6.

How can I recreate this issue?


Solution

  • I think you can refer to the code by gwoolsey at JDK-6611637. I was able to reproduce the problem with this.