java.lang.ArrayStoreException in java.util.Hashset
Here is the stack trace :
java.lang.ArrayStoreException
at java.util.HashMap.transfer(Unknown Source)
at java.util.HashMap.resize(Unknown Source)
at java.util.HashMap.addEntry(Unknown Source)
at java.util.HashMap.put(Unknown Source)
at java.util.HashSet.add(Unknown Source)
Some observations :
- Its an intermittent issue
- JDK 1.6
- CentOS 5.3
As I understand this error is intermittent I suspect it occurs whenever the HashSet (hence underlying HashMap) needs to resize itself. But not sure why this ArrayStoreException
. Now what I want to know is
-What are the scenarios wherein this error can occur ?
My guess is that you're trying to update the set from multiple threads concurrently. HashSet
and HashMap
aren't designed to be thread-safe - if you're going to access your set from multiple threads, you should use synchronization to prevent concurrent access.
That's just a guess, of course - without seeing your code I can't tell whether you are using multiple threads. It would go along with the intermittent side of things though...
精彩评论