[JBoss JIRA] Commented: (JBREM-552) cannot init cause of ClassCastException
by Jens Mueller (JIRA)
[ https://issues.jboss.org/browse/JBREM-552?page=com.atlassian.jira.plugin.... ]
Jens Mueller commented on JBREM-552:
------------------------------------
A very similar issue happens reproducibly in JBoss 4.2.3.GA when first after deployment inserting an element in a Google Guava Map created with new MapMaker().softValues().maximumSize(cacheSize).makeMap():
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)
...
Debugging in Throwable.initCause showed the original exception being a "ClassNotFoundException: Invalid use of destroyed classloader for com.google.common.collect.Iterators, UCL destroyed at:" 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
> cannot init cause of ClassCastException
> ---------------------------------------
>
> Key: JBREM-552
> URL: https://issues.jboss.org/browse/JBREM-552
> Project: JBoss Remoting
> Issue Type: Bug
> Security Level: Public(Everyone can see)
> Affects Versions: 2.0.0.Beta2 (Boon)
> Reporter: John Mazzitelli
> Assignee: Tom Elrod
> Priority: Minor
> Fix For: 2.0.0.CR1 (Boon)
>
>
> I'm in a catch clause within InvokerRegistry and I'm getting a weird exception thrown:
> java.lang.IllegalStateException: Can't overwrite cause
> at java.lang.Throwable.initCause(Throwable.java:320)
> at org.jboss.remoting.InvokerRegistry.loadClientInvoker(InvokerRegistry.java:447)
> at org.jboss.remoting.InvokerRegistry.createClientInvoker(InvokerRegistry.java:324)
> at org.jboss.remoting.Client.connect(Client.java:385)
> at org.jboss.on.communications.command.client.JBossRemotingRemoteCommunicator.getRemotingClient(JBossRemotingRemoteCommunicator.java:470)
> at org.jboss.on.communications.command.client.JBossRemotingRemoteCommunicator.send(JBossRemotingRemoteCommunicator.java:430)
> at org.jboss.on.communications.command.client.AbstractCommandClient.invoke(AbstractCommandClient.java:167)
> at org.jboss.on.communications.command.client.ClientCommandSender.send(ClientCommandSender.java:820)
> at org.jboss.on.communications.command.client.ServerPollingThread.run(ServerPollingThread.java:102)
> Look at line 447 and you'll see it is trying to init the cause of a ClassNotFoundException. Running in a debugger, the newly constructed exception created on 446 has a null cause. Looking then at Throwable.initCause and you'll see a null cause causes this IllegalStateException to be thrown. The cause needs to be "this", not null (I don't know why, seems like it should also look for null, but whatever - that's the way the JDK is written).
> The fix is simple - use the constructor that takes a throwable as its second parameter. Not sure why initCause it being used, as opposed to this constructor.
> e.g.:
> new ClassNotFoundException("Can not invoke loadClientInvokerClass method on " + transportFactoryClass, e);
> (notice the ", e" parameter).
> There are three other instances where initCause is called on ClassNotFoundException that also need to be fixed. See the other catch clauses in here.
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
13 years, 3 months