harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From telli...@apache.org
Subject svn commit: r533960 - in /harmony/enhanced/classlib/trunk/modules/beans/src: main/java/java/beans/Beans.java test/java/org/apache/harmony/beans/tests/java/beans/BeansTest.java
Date Tue, 01 May 2007 08:13:29 GMT
Author: tellison
Date: Tue May  1 01:13:27 2007
New Revision: 533960

URL: http://svn.apache.org/viewvc?view=rev&rev=533960
Log:
Apply patch HARMONY-3776 ([classlib][beans]Beans.instantiate() should throw IOException if
problem occurs during processing serialization file)

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

Modified: harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/Beans.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/Beans.java?view=diff&rev=533960&r1=533959&r2=533960
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/Beans.java (original)
+++ harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/Beans.java Tue
May  1 01:13:27 2007
@@ -67,19 +67,9 @@
                 .getSystemResourceAsStream(beanResourceName) : cls
                 .getResourceAsStream(beanResourceName);
 
-        if (is != null) {
-            try {
-                ObjectInputStream ois = (cls == null) ? new ObjectInputStream(
-                        is) : new CustomizedObjectInputStream(is, cls);
-
-                try {
-                    result = ois.readObject();
-                } catch (ClassNotFoundException cnfe) {
-                    // skip exception
-                }
-            } catch (IOException ioe) {
-                // skip exception
-            }
+        if (is != null) {            
+            ObjectInputStream ois = (cls == null) ? new ObjectInputStream(is) : new CustomizedObjectInputStream(is,
cls);
+            result = ois.readObject();
         }
 
         if (result == null) {

Modified: harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/BeansTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/BeansTest.java?view=diff&rev=533960&r1=533959&r2=533960
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/BeansTest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/BeansTest.java
Tue May  1 01:13:27 2007
@@ -23,6 +23,8 @@
 import java.beans.beancontext.BeanContext;
 import java.beans.beancontext.BeanContextSupport;
 import java.io.Externalizable;
+import java.io.File;
+import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.ObjectInput;
@@ -423,6 +425,24 @@
         // null targetType
         targetType = null;
         assertFalse(Beans.isInstanceOf(bean, targetType));
+    }
+    
+    public void test_instantiate_with_corrupted_serialization_file()
+            throws Exception {
+        final String BEANS_NAME = "TestBean";
+
+        // create a corrupted serialization file with name TestBean.ser
+        File file = new File(BEANS_NAME + ".ser");
+        file.deleteOnExit();
+        FileOutputStream fout = new FileOutputStream(file);
+        fout.close();       
+
+        try {
+            Beans.instantiate(null, BEANS_NAME);
+            fail("should throw IOException.");
+        } catch (IOException e) {
+            // expected
+        }
     }
 
     /**



Mime
View raw message