[jboss-jira] [JBoss JIRA] Commented: (JGRP-417) ConnectionTable.run / ClassCastException with IBM Java 1.5

Bela Ban (JIRA) jira-events at lists.jboss.org
Fri Feb 16 07:07:36 EST 2007


    [ http://jira.jboss.com/jira/browse/JGRP-417?page=comments#action_12353339 ] 
            
Bela Ban commented on JGRP-417:
-------------------------------

I still don't see this:

synchronized(conns) {
     if(conns.containsKey(peer_addr)) { // this should not throw a CCE
     }
}

Map.containsKey(IpAddress) will *not* compare peer_addr against a Connection object ! As you can see, the only conns.put() in the class places an IpAddress into the conns hashmap as key, so this guarantees there are only IpAddress instances in conns as keys.

So how did you arrive at the CCE ? Can you reproduce this ?

> ConnectionTable.run / ClassCastException with IBM Java 1.5
> ----------------------------------------------------------
>
>                 Key: JGRP-417
>                 URL: http://jira.jboss.com/jira/browse/JGRP-417
>             Project: JGroups
>          Issue Type: Bug
>    Affects Versions: 2.2.9 SP4
>         Environment: $ java -version
> java version "1.5.0"
> Java(TM) 2 Runtime Environment, Standard Edition (build pxi32devifx-20061107 (iFix 111765: SR3 + 111700) )
> IBM J9 VM (build 2.3, J2RE 1.5.0 IBM J9 2.3 Linux x86-32 j9vmxi3223-20061001 (JIT enabled)
> J9VM - 20060915_08260_lHdSMR
> JIT  - 20060908_1811_r8
> GC   - 20060906_AA)
> JCL  - 20061107
>            Reporter: Yves Martin
>         Assigned To: Bela Ban
>             Fix For: 2.5
>
>
> When migrating a project to IBM Java 1.5,
> I get the following warning from ConnectionTable:
> ConnectionTable.run(): exception is java.lang.ClassCastException: IpAddress.compareTo(): comparison between different classes
> And communication times out.
> The same code works perfectly well with Sun Java 1.5.0_07
> The drop stack trace show it comes from Hashtable.contains.
> After comparison between Sun src.zip and IBM src.jar for Hashtable,
> . Sun does entry.equals(value)
> . IBM does value.equals(entry)
> As a result, JGroups happens to do a IpAddress.equals(Connection) with IBM JVM
> and fails. Whereas Connection.equals(IpAddress) is properly handled in case of Sun JVM.
> Patch is trivial but the bug analysis was difficult !!
> Here is a valid IpAddress.equals method.
>     public boolean equals(Object obj) {
>         if (obj == null || !(obj instanceof IpAddress)) return false;
>         return compareTo(obj) == 0 ? true : false;
>     }
> Thank you in advance to include this patch in JGroups 2.2.9 so that JBoss 4.0.x may work one day with IBM Java 1.5

-- 
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