IllegalStateException:无法覆盖Guava map.put中的原因 [英] IllegalStateException: Can't overwrite cause in Guava map.put

查看:99
本文介绍了IllegalStateException:无法覆盖Guava map.put中的原因的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用

new MapMaker().softValues().maximumSize(cacheSize).makeMap();

这似乎工作正常,但是,在部署之后,我有时会在访问后获得以下异常服务器并将新元素放入地图:

This seemed to work fine, however, I sometimes get the following exception after accessing right after deploying on the server and putting new elements into the map:

java.lang.IllegalStateException: Can't overwrite cause
  at java.lang.Throwable.initCause(Throwable.java:320)
  at org.jboss.mx.loading.RepositoryClassLoader.findClass(RepositoryClassLoader.java:624)
  at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
  at org.jboss.mx.loading.RepositoryClassLoader.loadClassImpl(RepositoryClassLoader.java:474)
  at org.jboss.mx.loading.RepositoryClassLoader.loadClass(RepositoryClassLoader.java:415)
  at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
  at com.google.common.collect.CustomConcurrentHashMap$2.iterator(CustomConcurrentHashMap.java:828)
  at java.util.AbstractCollection.remove(AbstractCollection.java:241)
  at com.google.common.collect.CustomConcurrentHashMap$Segment.removeFromChain(CustomConcurrentHashMap.java:2599)
  at com.google.common.collect.CustomConcurrentHashMap$Segment.processPendingCleanup(CustomConcurrentHashMap.java:2772)
  at com.google.common.collect.CustomConcurrentHashMap$Segment.runLockedCleanup(CustomConcurrentHashMap.java:2860)
  at com.google.common.collect.CustomConcurrentHashMap$Segment.preWriteCleanup(CustomConcurrentHashMap.java:2806)
  at com.google.common.collect.CustomConcurrentHashMap$Segment.put(CustomConcurrentHashMap.java:2374)
  at com.google.common.collect.CustomConcurrentHashMap.put(CustomConcurrentHashMap.java:3346)
  at my.app.cache.CacheImplGoogleGuava.put(CacheImplGoogleGuava.java:36)
...

可能是什么原因?

---更新:

JBoss版本为5.

JBoss version is 5.

在Throwable.initCause中设置断点,显示 ClassNotFoundException ,带消息:
无效使用destro com.google.common.collect.Iterators的yed classloader,UCL在以下地址销毁:
和Stacktrace

Setting a breakpoint in Throwable.initCause revealed ClassNotFoundException with message: Invalid use of destroyed classloader for com.google.common.collect.Iterators, UCL destroyed at: and with Stacktrace

ClassNotFoundException(Throwable).initCause(Throwable):320
UnifiedClassLoader3(RepositoryClassLoader).findClass(String):628
...
UnifiedClassLoader3(ClassLoader).loadClass(String):248
CustomConcurrentHashMap$2.iterator():828
CustomConcurrentHashMap$2(AbstractCollection<E>).remove(Object):241
CustomConcurrentHashMap$Segment.enqueueCleanup(...):2738
CustomConcurrentHashMap$Segment.unsetValue(...):2662
CustomConcurrentHashMap<K, V>.reclaimValue(...)
CustomConcurrentHashMap$SoftValueReference<K, V>.finalizeReferent():1637
...
Method.invoke:574
Finalizer.claenUp:154
Finalizer.run:127

从堆栈跟踪中,似乎地图中的对象最终确定在 finalizeReferent com.google.common.collect.Iterators 无法加载。

From the stacktrace, it seems as if an object in the map was finalized where in finalizeReferent the class com.google.common.collect.Iterators cannot be loaded.

推荐答案

您的问题似乎与 MapMaker无关或一般的番石榴。

Your problem seems to be unrelated to MapMaker or Guava in general.

你只看到处理另一个异常时发生的异常(不幸的是)。

You only see an exception that happens while handling another exception (unfortunately).

Throwable.initCause()在调用异常时抛出异常,同时已经为当前 Throwable指定了原因(通过方法或构造函数`。

Throwable.initCause() throws an exception when it's called while there was already a cause specified for the current Throwable (either via the method or the constructor`.

RepositoryClassLoader.findClass()方法似乎处理一些它预期没有原因的异常,但事实上它已经有一个原因设置,触发了这个异常。

The RepositoryClassLoader.findClass() method seems to be handling some exception that it expects not to have a cause, but in fact it already has a cause set, which triggers this exception.

不幸的是,你在这里看到的异常隐藏实际的异常(对于解决问题可能更为重要)。

Unfortunately the exception you see here hides the actual exception (which would probably be much more important for solving the problem).

尝试将破坏点放在 Throwable.initCause()第320行或 RepositoryClassLoader.findClass()(在第624行)并重现问题(希望)在IDE的局部变量视图中看到真实异常。

Try to put a breakpoit at Throwable.initCause() at line 320 or at RepositoryClassLoader.findClass() (at line 624) and reproduce the problem to (hopefully) see the "real" exception in the local variables view of your IDE.

这篇关于IllegalStateException:无法覆盖Guava map.put中的原因的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆