You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by di...@apache.org on 2006/05/19 21:29:27 UTC

svn commit: r407889 - /webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/utils/BeanUtil.java

Author: dims
Date: Fri May 19 12:29:26 2006
New Revision: 407889

URL: http://svn.apache.org/viewvc?rev=407889&view=rev
Log:
- *PLEASE* don't catch all exceptions and return null
- Adding check for NPE's.


Modified:
    webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/utils/BeanUtil.java

Modified: webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/utils/BeanUtil.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/utils/BeanUtil.java?rev=407889&r1=407888&r2=407889&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/utils/BeanUtil.java (original)
+++ webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/utils/BeanUtil.java Fri May 19 12:29:26 2006
@@ -49,7 +49,7 @@
      * @param beanName
      */
     public static XMLStreamReader getPullParser(Object beanObject, QName beanName) {
-        try {
+		try {
             JamServiceFactory factory = JamServiceFactory.getInstance();
             JamServiceParams jam_service_parms = factory.createServiceParams();
             jam_service_parms.addClassLoader(beanObject.getClass().getClassLoader());
@@ -88,7 +88,7 @@
                     Object value = propDesc.getReadMethod().invoke(beanObject,
                             (Object[]) null);
                     object.add(propDesc.getName());
-                    object.add(value.toString());
+                    object.add(value == null ? null : value.toString());
                 } else if (ptype.isArray()) {
                     Object value [] = (Object[]) propDesc.getReadMethod().invoke(beanObject,
                             (Object[]) null);
@@ -96,7 +96,7 @@
                         for (int j = 0; j < value.length; j++) {
                             Object o = value[j];
                             object.add(propDesc.getName());
-                            object.add(o.toString());
+                            object.add(o == null ? null :o.toString());
                         }
                     } else {
                         for (int j = 0; j < value.length; j++) {
@@ -134,9 +134,15 @@
                 }
             }
             return new ADBXMLStreamReaderImpl(beanName, object.toArray(), null);
-        } catch (Exception e) {
-            return null;
-        }
+		} catch (java.io.IOException e){
+			throw new RuntimeException(e);
+		} catch (java.beans.IntrospectionException e){
+			throw new RuntimeException(e);
+		} catch (java.lang.reflect.InvocationTargetException e){
+			throw new RuntimeException(e);
+		} catch (java.lang.IllegalAccessException e){
+			throw new RuntimeException(e);
+		}
     }
 
     /**
@@ -455,7 +461,7 @@
                     Object o = array[j];
                     if (SimpleTypeMapper.isSimpleType(o)) {
                         objects.add("item" + argCount);
-                        objects.add(o.toString());
+                        objects.add(o == null ? null : o.toString());
                     } else {
                         objects.add(new QName("item" + argCount));
                         if (o instanceof OMElement) {



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