harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From telli...@apache.org
Subject svn commit: r785149 - in /harmony/enhanced/classlib/trunk/modules/beans/src: main/java/java/beans/XMLDecoder.java test/java/org/apache/harmony/beans/tests/java/beans/XMLDecoderTest.java
Date Tue, 16 Jun 2009 10:32:43 GMT
Author: tellison
Date: Tue Jun 16 10:32:42 2009
New Revision: 785149

URL: http://svn.apache.org/viewvc?rev=785149&view=rev
Log:
Apply patch for HARMONY-6213 ([classlib][beans] XMLDecoder.readObject() should not invoke
org.xml.sax.SAXParseException)

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

Modified: harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/XMLDecoder.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/XMLDecoder.java?rev=785149&r1=785148&r2=785149&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/XMLDecoder.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/XMLDecoder.java
Tue Jun 16 10:32:42 2009
@@ -529,6 +529,8 @@
 
     private int readObjIndex = 0;
 
+    private SAXHandler saxHandler = null;
+
     /**
      * Create a decoder to read from specified input stream.
      * 
@@ -616,11 +618,14 @@
      */
     @SuppressWarnings("nls")
     public Object readObject() {
-        try {
-            SAXParserFactory.newInstance().newSAXParser().parse(inputStream,
-                    new SAXHandler());
-        } catch (Exception e) {
-            this.listener.exceptionThrown(e);
+        if (saxHandler == null) {
+            saxHandler = new SAXHandler();
+            try {
+                SAXParserFactory.newInstance().newSAXParser().parse(
+                        inputStream, saxHandler);
+            } catch (Exception e) {
+                this.listener.exceptionThrown(e);
+            }
         }
         
         if (readObjIndex >= readObjs.size()) {

Modified: harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/XMLDecoderTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/XMLDecoderTest.java?rev=785149&r1=785148&r2=785149&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/XMLDecoderTest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/XMLDecoderTest.java
Tue Jun 16 10:32:42 2009
@@ -430,6 +430,25 @@
         assertEquals(o2, t2.getV());
     }
 
+    public void testReadObject_Repeated() throws Exception {
+        final Vector<Exception> exceptionList = new Vector<Exception>();
+
+        final ExceptionListener exceptionListener = new ExceptionListener() {
+            public void exceptionThrown(Exception e) {
+                exceptionList.addElement(e);
+            }
+        };
+
+        XMLDecoder xmlDecoder = new XMLDecoder(new ByteArrayInputStream(
+                xml123bytes));
+        xmlDecoder.setExceptionListener(exceptionListener);
+        assertEquals(new Integer(1), xmlDecoder.readObject());
+        assertEquals(new Integer(2), xmlDecoder.readObject());
+        assertEquals(new Integer(3), xmlDecoder.readObject());
+        xmlDecoder.close();
+        assertEquals(0, exceptionList.size());
+    }
+
     public void testSetExceptionListener_Called() throws Exception {
         class MockExceptionListener implements ExceptionListener {
 



Mime
View raw message