harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chunr...@apache.org
Subject svn commit: r725765 - in /harmony/enhanced/classlib/trunk/modules/beans/src: main/java/java/beans/StandardBeanInfo.java test/java/org/apache/harmony/beans/tests/java/beans/IntrospectorTest.java
Date Thu, 11 Dec 2008 18:20:00 GMT
Author: chunrong
Date: Thu Dec 11 10:19:59 2008
New Revision: 725765

URL: http://svn.apache.org/viewvc?rev=725765&view=rev
Log:
Apply patch for HARMONY-6038, NPE in java.beans.Introspector.getBeanInfo

Modified:
    harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/StandardBeanInfo.java
    harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/IntrospectorTest.java

Modified: harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/StandardBeanInfo.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/StandardBeanInfo.java?rev=725765&r1=725764&r2=725765&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/StandardBeanInfo.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/StandardBeanInfo.java
Thu Dec 11 10:19:59 2008
@@ -291,8 +291,8 @@
                 // Sub is PropertyDescriptor
                 if (subIndexedType == null) {
                     // Same property type
-                    if (subType != null &&
-                            subType.getName().equals(superType.getName())) {
+                    if (subType != null && superType != null
+                            && subType.getName().equals(superType.getName())) {
                         if ((subGet == null) && (superGet != null)) {
                             subDesc.setReadMethod(superGet);
                         }
@@ -306,7 +306,8 @@
                         }
                     }
                 } else { // Sub is IndexedPropertyDescriptor
-                    if ((superType.isArray())
+                    if (superType != null
+                            && (superType.isArray())
                             && (superType.getComponentType().getName()
                                     .equals(subIndexedType.getName()))) {
                         // same type
@@ -321,7 +322,8 @@
                 subMap.put(propertyName, subDesc);
             } else { // Super is IndexedPropertyDescriptor
                 if (subIndexedType == null) { // Sub is PropertyDescriptor
-                    if (subType.isArray()
+                    if (subType != null
+                            && subType.isArray()
                             && (subType.getComponentType().getName()
                                     .equals(superIndexedType.getName()))) {
                         // Same type
@@ -336,8 +338,9 @@
                         subMap.put(propertyName, (PropertyDescriptor) value);
                     }
 
-                } else if (subIndexedType.getName().equals(
-                        superIndexedType.getName())) {
+                } else if (superIndexedType != null
+                        && subIndexedType.getName().equals(
+                                superIndexedType.getName())) {
                     // Sub is IndexedPropertyDescriptor and Same type
                     IndexedPropertyDescriptor subDesc = (IndexedPropertyDescriptor) value;
                     if ((subGet == null) && (superGet != null)) {

Modified: harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/IntrospectorTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/IntrospectorTest.java?rev=725765&r1=725764&r2=725765&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/IntrospectorTest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/IntrospectorTest.java
Thu Dec 11 10:19:59 2008
@@ -869,6 +869,39 @@
         }
     }
     
+    /*
+     * @test Introspector.getBeanInfo
+     * @test StandardBeanInfo.mergeProps
+     */
+    public void testGetBeanInfo_StandardBeanInfo_mergeProps() throws Exception {
+        class MockParent {
+            public void setValue(int v) {
+                // do nothing
+            }
+
+            public void setValue(int v, String s) {
+                // do nothing
+            }
+        }
+
+        class MockChild extends MockParent {
+            public void setValue(int v) {
+                // do nothing
+            }
+        }
+
+        BeanInfo beanInfo = Introspector.getBeanInfo(MockChild.class);
+        PropertyDescriptor[] pds = beanInfo.getPropertyDescriptors();
+        PropertyDescriptor pd = null;
+        for(int i = 0; i < pds.length; i++){
+            if("value".equals(pds[i].getName())){
+                pd = pds[i];
+            }
+        }
+        assertNotNull(pd);
+        assertEquals(Integer.TYPE, pd.getPropertyType());
+    }
+    
     public void testSetBeanInfoSearchPath_null() throws IntrospectionException{
         String[] oldPath = Introspector.getBeanInfoSearchPath();
         try{



Mime
View raw message