java.util.Hashset 中的 java.lang.ArrayStoreException
这是堆栈跟踪:
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)
一些观察结果:
- 它是一个间歇性问题
- JDK 1.6
- CentOS 5.3
据我了解,此错误是间歇性的,我怀疑每当 HashSet(因此底层 HashMap)需要调整自身大小时就会发生它。但不确定为什么会出现此ArrayStoreException
。现在我想知道的是
- 在什么情况下会发生此错误?
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 ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我的猜测是您正在尝试同时从多个线程更新该集合。
HashSet
和HashMap
并非设计为线程安全的 - 如果您要从多个线程访问您的集合,则应使用同步来防止并发访问。当然,这只是一个猜测 - 如果没有看到您的代码,我无法判断您是否正在使用多个线程。不过,它会伴随着事物间歇性的一面......
My guess is that you're trying to update the set from multiple threads concurrently.
HashSet
andHashMap
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...