[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kandula-dev
Subject:    [jira] Created: (AXIS2-4968) Inconsistent wsdl2java generation with
From:       "Konstantinos Mavridis (JIRA)" <jira () apache ! org>
Date:       2011-02-28 15:54:37
Message-ID: 158924322.1822.1298908477069.JavaMail.tomcat () hel ! zones ! apache ! org
[Download RAW message or body]

Inconsistent wsdl2java generation with IBM JDK 6.0SR8FP1
--------------------------------------------------------

                 Key: AXIS2-4968
                 URL: https://issues.apache.org/jira/browse/AXIS2-4968
             Project: Axis2
          Issue Type: Bug
          Components: codegen
    Affects Versions: 1.5.4, 1.5.1
         Environment: Microsoft Windows XP (32-bit), IBM JDK 6.0SR8FP1
            Reporter: Konstantinos Mavridis
            Priority: Critical


Initially, we opened an issue against IBM. After investigation the issue appeared to \
originate from Axis2/WS Common XmlSchema. Below is the response from IBM:

The problem does appear to be in the Apache ws-commons code             
or a combination of that and the way the Axis2 code uses the            
ws-commons code.                                                        
                                                                        
The org.apache.axis2.schema.SchemaCompiler class has a field named      
processedAnonymousComplexTypesMap, which is a HashMap whose keys are    
instances of org.apache.ws.commons.schema.XmlSchemaElement.  That is,   
an anonymous complex types is looked up using the schema element that   
contains it.                                                            
                                                                        
I believe the problem is that XmlSchemaElement inherits its             
equals(Object) method from the XmlSchemaObject class.  That equals      
method compares the sourceURIs, the line numbers and line positions of  
the two objects.  However, in the Axis2 usage, it seems that the        
sourceURIs are always null, and the line numbers and line positions are 
always zero, so the XmlSchemaObject.equals method always returns true in
the Axis2 usage.                                                        
                                                                        
On occasion the hashCode() of two XmlSchemaElement instances is equal.  
Duplicate values are somewhat rare, but they do happen, apparently      
randomly.  When the hashCode() values of two XmlSchemaElement instances 
are the same, and they both contain anonymous complex types, the first  
is entered into the processedAnonymousComplexTypesMap HashMap using the 
first XmlSchemaElement as the key.  The second XmlSchemaElement is      
subsequently used as a key in entering the second anonymous complex     
type.  Because the hashCode() values are equal, the HashMap finds that  
there is already a key with the same hashCode(), so it calls the        
equals(Object) method to see whether the two keys are equal.  The equals
method returns true, so the second anonymous complex type is stored as  
the value associated with the first XmlSchemaElement.

We suspect that the SUN JDK just has a         
different hashing algorithm.  It is not required to produce distinct    
hash codes for distinct objects as the java.lang.Object documentation   
for the hashCode method states:                                         
                                                                        
It is not required that if two objects are unequal according to the     
equals(java.lang.Object)  method, then calling the hashCode method on   
each of the two objects must produce distinct integer results.          

For each axis2 object to be treated distinctly, an IdentityHashMap must be used.

Workaround:
Modify the Apache WS Commons XmlSchemaElement class overwriting the 
hashCode method.
                                                                        
 private static int counter = 1;                                        
 private int hashCode = -1;                                             
                                                                        
 public int hashCode() {                                                
  if (hashCode == -1) {                                                 
   hashCode = counter++;                                                
  }                                                                     
  return hashCode;                                                      
 }      

-- 
This message is automatically generated by JIRA.
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: java-dev-unsubscribe@axis.apache.org
For additional commands, e-mail: java-dev-help@axis.apache.org


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic