incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r1408640 - /sling/trunk/contrib/extensions/rewriter/src/main/java/org/apache/sling/rewriter/impl/PipelineImpl.java
Date Tue, 13 Nov 2012 08:52:15 GMT
Author: cziegeler
Date: Tue Nov 13 08:52:15 2012
New Revision: 1408640

URL: http://svn.apache.org/viewvc?rev=1408640&view=rev
Log:
SLING-2661 :  Components might not be disposed if exception is occuring 

Modified:
    sling/trunk/contrib/extensions/rewriter/src/main/java/org/apache/sling/rewriter/impl/PipelineImpl.java

Modified: sling/trunk/contrib/extensions/rewriter/src/main/java/org/apache/sling/rewriter/impl/PipelineImpl.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/rewriter/src/main/java/org/apache/sling/rewriter/impl/PipelineImpl.java?rev=1408640&r1=1408639&r2=1408640&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/rewriter/src/main/java/org/apache/sling/rewriter/impl/PipelineImpl.java
(original)
+++ sling/trunk/contrib/extensions/rewriter/src/main/java/org/apache/sling/rewriter/impl/PipelineImpl.java
Tue Nov 13 08:52:15 2012
@@ -181,39 +181,36 @@ public class PipelineImpl implements Pro
      * @see org.apache.sling.rewriter.Processor#finished(boolean)
      */
     public void finished(final boolean errorOccured) throws IOException {
-        IOException ioe = null;
-        // if an error occurred, we only clean up
-        if ( !errorOccured ) {
-            try {
-                this.generator.finished();
-            } catch (final IOException localIOE) {
-                ioe = localIOE;
-            } catch (final SAXException se) {
-                if ( se.getCause() != null && se.getCause() instanceof IOException
) {
-                    ioe = (IOException)se.getCause();
-                } else {
-                    ioe = new IOException("Pipeline exception: " + se.getMessage());
-                    ioe.initCause(se);
+        try {
+            // if an error occurred, we only clean up
+            if ( !errorOccured ) {
+                try {
+                    this.generator.finished();
+                } catch (final SAXException se) {
+                    if ( se.getCause() != null && se.getCause() instanceof IOException
) {
+                        throw (IOException)se.getCause();
+                    } else {
+                        final IOException ioe = new IOException("Pipeline exception: " +
se.getMessage());
+                        ioe.initCause(se);
+                        throw ioe;
+                    }
                 }
             }
-        }
-        // now dispose components
-        if ( this.generator != null ) {
-            this.generator.dispose();
-        }
-        if ( this.transformers != null ) {
-            for(final Transformer transformer : this.transformers ) {
-                if ( transformer != null ) {
-                    transformer.dispose();
+        } finally {
+            // dispose components
+            if ( this.generator != null ) {
+                this.generator.dispose();
+            }
+            if ( this.transformers != null ) {
+                for(final Transformer transformer : this.transformers ) {
+                    if ( transformer != null ) {
+                        transformer.dispose();
+                    }
                 }
             }
-        }
-        if ( this.serializer != null ) {
-            this.serializer.dispose();
-        }
-        // throw exception
-        if ( ioe != null ) {
-            throw ioe;
+            if ( this.serializer != null ) {
+                this.serializer.dispose();
+            }
         }
     }
 



Mime
View raw message