harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From telli...@apache.org
Subject svn commit: r447834 - in /incubator/harmony/enhanced/classlib/trunk/modules/beans/src: main/java/org/apache/harmony/beans/DefaultPersistenceDelegatesFactory.java test/java/org/apache/harmony/beans/tests/java/beans/EncoderTest.java
Date Tue, 19 Sep 2006 12:43:24 GMT
Author: tellison
Date: Tue Sep 19 05:43:24 2006
New Revision: 447834

URL: http://svn.apache.org/viewvc?view=rev&rev=447834
Log:
Apply patch HARMONY-1303 ([classlib][beans] unexpected NPE for Encoder.getPersistenceDelegate(null))

Modified:
    incubator/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/org/apache/harmony/beans/DefaultPersistenceDelegatesFactory.java
    incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/EncoderTest.java

Modified: incubator/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/org/apache/harmony/beans/DefaultPersistenceDelegatesFactory.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/org/apache/harmony/beans/DefaultPersistenceDelegatesFactory.java?view=diff&rev=447834&r1=447833&r2=447834
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/org/apache/harmony/beans/DefaultPersistenceDelegatesFactory.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/org/apache/harmony/beans/DefaultPersistenceDelegatesFactory.java
Tue Sep 19 05:43:24 2006
@@ -35,8 +35,11 @@
     private static HashMap<String, PersistenceDelegate> persistenceDelegates = new
HashMap<String, PersistenceDelegate>();
 
     private static PersistenceDelegate createPersistenceDelegate(Class type) {
-        PersistenceDelegate pd = null;
+        if (type == null) {
+            return new NullPersistenceDelegate();
+        }
 
+        PersistenceDelegate pd = null;
         try {
             String className = createDefaultNameForPersistenceDelegateClass(type);
 
@@ -64,11 +67,11 @@
     }
 
     public static PersistenceDelegate getPersistenceDelegate(Class type) {
-        String className = type.getName();
+        String className = (type == null) ? null : type.getName();
         PersistenceDelegate result = persistenceDelegates.get(className);
 
         if (result == null) {
-            if (type.isArray()) {
+            if (type != null && type.isArray()) {
                 result = org.apache.harmony.beans.ArrayPersistenceDelegate
                         .getInstance();
             } else {

Modified: incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/EncoderTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/EncoderTest.java?view=diff&rev=447834&r1=447833&r2=447834
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/EncoderTest.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/EncoderTest.java
Tue Sep 19 05:43:24 2006
@@ -346,10 +346,9 @@
 	}
 
 	public void testGetPersistenceDelegate_Null() {
-		// TODO different behavior
-		// MockEncoder enc = new MockEncoder();
-		// PersistenceDelegate pd = enc.getPersistenceDelegate(null);
-		// assertNotNull(pd);
+		MockEncoder enc = new MockEncoder();
+		PersistenceDelegate pd = enc.getPersistenceDelegate(null);
+		assertNotNull(pd);
 	}
 
 	public void testGetPersistenceDelegate_ArrayClass() {



Mime
View raw message