igors       02/04/09 16:41:12

  Modified:    java/src/org/apache/axis/encoding/ser BeanSerializer.java
  Log:
  Check for null before using the object
  
  Revision  Changes    Path
  1.26      +32 -30    
xml-axis/java/src/org/apache/axis/encoding/ser/BeanSerializer.java
  
  Index: BeanSerializer.java
  ===================================================================
  RCS file: 
/home/cvs/xml-axis/java/src/org/apache/axis/encoding/ser/BeanSerializer.java,v
  retrieving revision 1.25
  retrieving revision 1.26
  diff -u -r1.25 -r1.26
  --- BeanSerializer.java       4 Apr 2002 22:30:24 -0000       1.25
  +++ BeanSerializer.java       9 Apr 2002 23:41:12 -0000       1.26
  @@ -168,36 +168,38 @@
                   }
   
                   Method readMethod = propertyDescriptor[i].getReadMethod();
  -                Class baseJavaType = readMethod.getReturnType();
  -                Class javaType;
  -                if (readMethod != null && 
  -                    readMethod.getParameterTypes().length == 0) {
  -                    // Normal case: serialize the value
  -                    Object propValue = readMethod.invoke(value,noArgs);
  -                    javaType = (propValue == null || baseJavaType.isPrimitive())
  -                        ? baseJavaType : propValue.getClass();
  -                    context.serialize(qname,
  -                                      null,
  -                                      propValue, javaType);
  -                } else {
  -                    // Collection of properties: serialize each one
  -                    int j=0;
  -                    while(j >= 0) {
  -                        Object propValue = null;
  -                        try {
  -                            propValue = 
  -                                readMethod.invoke(value,
  -                                     new Object[] { new Integer(j) });
  -                            j++;
  -                        } catch (Exception e) {
  -                            j = -1;
  -                        }
  -                        if (j >= 0) {
  -                            javaType = (propValue == null || 
  -                                        baseJavaType.isPrimitive())
  -                                ? baseJavaType : propValue.getClass();
  -                            context.serialize(qname, null,
  -                                              propValue, javaType);
  +                // if there is a read method for a property
  +                if(readMethod != null) {
  +                    Class baseJavaType = readMethod.getReturnType();
  +                    Class javaType;
  +                    if (readMethod.getParameterTypes().length == 0) {
  +                        // Normal case: serialize the value
  +                        Object propValue = readMethod.invoke(value,noArgs);
  +                        javaType = (propValue == null || baseJavaType.isPrimitive())
  +                            ? baseJavaType : propValue.getClass();
  +                        context.serialize(qname,
  +                                          null,
  +                                          propValue, javaType);
  +                    } else {
  +                        // Collection of properties: serialize each one
  +                        int j=0;
  +                        while(j >= 0) {
  +                            Object propValue = null;
  +                            try {
  +                                propValue = 
  +                                    readMethod.invoke(value,
  +                                         new Object[] { new Integer(j) });
  +                                j++;
  +                            } catch (Exception e) {
  +                                j = -1;
  +                            }
  +                            if (j >= 0) {
  +                                javaType = (propValue == null || 
  +                                            baseJavaType.isPrimitive())
  +                                    ? baseJavaType : propValue.getClass();
  +                                context.serialize(qname, null,
  +                                                  propValue, javaType);
  +                            }
                           }
                       }
                   }
  
  
  


Reply via email to