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 2003/08/29 19:56:25 UTC

DO NOT REPLY [Bug 22819] New: - TypeDesc problems

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=22819>.
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=22819

TypeDesc problems

           Summary: TypeDesc problems
           Product: Axis
           Version: current (nightly)
          Platform: Other
        OS/Version: Other
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: Basic Architecture
        AssignedTo: axis-dev@ws.apache.org
        ReportedBy: gawor@mcs.anl.gov


Problem 1:

When registering a type mapping for a bean using call.registerTypeMapping
(Class, QName, Class, Class, boolean) method from multiple threads at the same 
time three things might happen:
A) The type mapping is registered successfully (*)
B) The type mapping is registered successfully but the number of fields in the 
TypeDesc of the bean (TypeDesc.getTypeDescForClass(<bean>).getFields().length) 
is incorrect.
C) The type mapping registration fails (internal error):
java.lang.ArrayIndexOutOfBoundsException
	at java.lang.System.arraycopy(Native Method)
	at org.apache.axis.description.TypeDesc.getFields(TypeDesc.java:212)
	at org.apache.axis.utils.BeanUtils.processPropertyDescriptors
(BeanUtils.java:259)
	at org.apache.axis.utils.BeanUtils.getPd(BeanUtils.java:103)
	at org.apache.axis.description.TypeDesc.getPropertyDescriptors
(TypeDesc.java:470)
	at org.apache.axis.encoding.ser.BeanSerializerFactory.<init>
(BeanSerializerFactory.java:88)
	at java.lang.reflect.Constructor.newInstance(Native Method)
	at org.apache.axis.encoding.ser.BaseSerializerFactory.createFactory
(BaseSerializerFactory.java:256)
	at org.apache.axis.client.Call.registerTypeMapping(Call.java:2069)

Solution:

TypeDesc.getPropertyDescriptors() should be synchronized (same should be 
probably done for getPropertyDescriptorMap() and getAnyContentDescriptor())

Problem 2:

TypeDesc.getFields(boolean) if called multiple times on the same instance 
(canSearchParents, searchParents are true and the javaClass extends some other 
bean) it will always increment the fields array by the number of fields found 
in the parent class (because the function updates the its own fields array each 
time called)
So even if type mapping is registered successfully without any error (as in 1-
A) the TypeDesc.getFields() array might contain invalid number of operations. 
That's because BeanUtil.processPropertyDescriptors() calls TypeDesc.getFields
(true) twice.

Solution:

The getFields(true) either shouldn't update its own fields array each time or 
update it once and then just return the updated array on subsequent calls.