[jboss-jira] [JBoss JIRA] Commented: (JBREM-552) cannot init cause of ClassCastException

John Mazzitelli (JIRA) jira-events at jboss.com
Thu Jul 20 12:59:11 EDT 2006


    [ http://jira.jboss.com/jira/browse/JBREM-552?page=comments#action_12339836 ] 
            
John Mazzitelli commented on JBREM-552:
---------------------------------------

The way this is now, its also bad because you lose all the cause stack traces as well.  So the context of where the problem actually occurred is lost.

Changing this to use the proper constructor should fix this

> cannot init cause of ClassCastException
> ---------------------------------------
>
>                 Key: JBREM-552
>                 URL: http://jira.jboss.com/jira/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
>         Assigned To: 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.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.jboss.com/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the jboss-jira mailing list