You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jackrabbit.apache.org by re...@apache.org on 2019/11/08 15:59:59 UTC

svn commit: r1869574 - in /jackrabbit/branches/2.16: ./ jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/SerializationTest.java

Author: reschke
Date: Fri Nov  8 15:59:59 2019
New Revision: 1869574

URL: http://svn.apache.org/viewvc?rev=1869574&view=rev
Log:
JCR-4484: jcr-tests: SerializationTest needs to cleanup after parse failures in import tests (merged r1867133 into 2.16)

Modified:
    jackrabbit/branches/2.16/   (props changed)
    jackrabbit/branches/2.16/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/SerializationTest.java

Propchange: jackrabbit/branches/2.16/
------------------------------------------------------------------------------
  Merged /jackrabbit/trunk:r1867133

Modified: jackrabbit/branches/2.16/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/SerializationTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/2.16/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/SerializationTest.java?rev=1869574&r1=1869573&r2=1869574&view=diff
==============================================================================
--- jackrabbit/branches/2.16/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/SerializationTest.java (original)
+++ jackrabbit/branches/2.16/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/SerializationTest.java Fri Nov  8 15:59:59 2019
@@ -249,18 +249,32 @@ public class SerializationTest extends A
         try {
             ih = session.getImportContentHandler(treeComparator.targetFolder,
                     ImportUUIDBehavior.IMPORT_UUID_CREATE_NEW);
+            helpTestSaxException(ih, in, "session");
         } catch (RepositoryException e) {
             fail("ImportHandler not created: " + e);
+        } finally {
+            closeContentHandler(ih);
         }
-        helpTestSaxException(ih, in, "session");
 
         in = new StringReader("<this is not a <valid> <xml> file/>");
         try {
             ih = workspace.getImportContentHandler(treeComparator.targetFolder, 0);
+            helpTestSaxException(ih, in, "workspace");
         } catch (RepositoryException e) {
             fail("ImportHandler not created: " + e);
+        } finally {
+            closeContentHandler(ih);
+        }
+    }
+
+    private static void closeContentHandler(ContentHandler ch) {
+        if (ch != null) {
+            try {
+                ch.endDocument();
+            } catch (SAXException e) {
+                // best effort
+            }
         }
-        helpTestSaxException(ih, in, "workspace");
     }
 
     /**
@@ -583,11 +597,19 @@ public class SerializationTest extends A
         if (useHandler) {
             if (useWorkspace) {
                 ContentHandler ih = workspace.getImportContentHandler(absPath, 0);
-                createXMLReader(ih).parse(new InputSource(in));
+                try {
+                    createXMLReader(ih).parse(new InputSource(in));
+                } finally {
+                    ih.endDocument();
+                }
             } else {
                 ContentHandler ih = session.getImportContentHandler(absPath, 0);
-                createXMLReader(ih).parse(new InputSource(in));
-                session.save();
+                try {
+                    createXMLReader(ih).parse(new InputSource(in));
+                    session.save();
+                } finally {
+                    ih.endDocument();
+                }
             }
         } else {
             if (useWorkspace) {