开发者

java.lang.ArrayStoreException in java.util.Hashset

开发者 https://www.devze.com 2023-04-07 15:35 出处:网络
开发者_Go百科Here is the stack trace : java.lang.ArrayStoreException at java.util.HashMap.transfer(Unknown Source)
开发者_Go百科

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 :

  1. Its an intermittent issue
  2. JDK 1.6
  3. 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...

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号