You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by bu...@apache.org on 2004/01/13 00:38:37 UTC

DO NOT REPLY [Bug 26078] New: - Java objects initialization code created using WSDL generator is not thread safe

DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=26078>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=26078

Java objects initialization code created using WSDL generator is not thread safe

           Summary: Java objects initialization code created using WSDL
                    generator is not thread safe
           Product: Axis
           Version: 1.1
          Platform: All
        OS/Version: Other
            Status: NEW
          Severity: Major
          Priority: Other
         Component: Serialization/Deserialization
        AssignedTo: axis-dev@ws.apache.org
        ReportedBy: mpermana@hotmail.com


I had this really bad problem which only happen on Sun 8 CPU machine and it 
happens sporaidcally. Like 1 out of 50 cases. And it is consistently happens 
and reproducible, once this problem show up, AXIS always fail to deserialize 
SOAP message. Each time it tries to parse a SOAP message, it'll throw 
InvalidElement exception.

I started by defining some WSDL schema of some object that has propery. Let's 
say my SOAP message will look like this:
   <Login>
      <Username>
      <Password>
   </Login>

AXIS will generate the class
   Login
and it's typeDesc will have a map for "Username" and "Password" 

What happened is the typeDesc for my java objects contains wrong map.

   org.apache.axis.description.TypeDesc

I have multiple threads started to access the generated AXIS class. This 
triggers the initialization of typeDesc. So multiple threads initialize it. The 
problem is at the function getPropertyDescriptorMap which tries to initialize 
the hash map propertyMap. According to javadoc, this map IS NOT THREAD SAFE. 
Especially when a class has many attributes (like 20 or so). This function 
keeps adding the attribute to the map. Which can cause the hashtable to rehash 
and grows, when multiple thread are modifying this map, this will messup and 
corrup the hashmap and caued the invalid exception.

    public Map getPropertyDescriptorMap() {
        // Return map if already set.
        if (propertyMap != null) {
            return propertyMap;
        }

        // Make sure properties exist
        if (propertyDescriptors == null) {
            getPropertyDescriptors();  
        }

        // Build the map
        propertyMap = new HashMap();
        for (int i = 0; i < propertyDescriptors.length; i++) {
            BeanPropertyDescriptor descriptor = propertyDescriptors[i];
            propertyMap.put(descriptor.getName(), descriptor);
        }
        return propertyMap;
    }

The fix for this is according to JavaDoc for hash map is to give a locking 
mechanism for propertyMap. I think the easiest is just declare the function as 
synchronized. Please someone fix this bug. 

I had to resort by calling all my generated classes getPropertyDescriptorMap in 
the beginning of my application to make sure all of them are initialized in a 
single thread properly. But this takes a lot of time escpecially I have many 
generated classes.

Contact me if you need more information.








Here's the exception I'm experiencing in my real world application:
Exception:
org.xml.sax.SAXException: Invalid element in 
com.actuate.schemas.ExecuteReportResponse - ErrorDescription
        at org.apache.axis.encoding.ser.BeanDeserializer.onStartChild
(BeanDeserializer.java:260)
        at org.apache.axis.encoding.DeserializationContextImpl.startElement
(DeserializationContextImpl.java:963)
        at org.apache.axis.message.SAX2EventRecorder.replay
(SAX2EventRecorder.java:198)
        at org.apache.axis.message.MessageElement.publishToHandler
(MessageElement.java:722)
        at org.apache.axis.message.RPCElement.deserialize(RPCElement.java:233)
        at org.apache.axis.message.RPCElement.getParams(RPCElement.java:347)