cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a.@apache.org
Subject [2/2] cxf git commit: [CXF-6228] Using XSLTFeature with large messages creates unremovable temporary files
Date Mon, 02 Feb 2015 21:46:16 GMT
[CXF-6228] Using XSLTFeature with large messages creates unremovable temporary files


Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/a9251eca
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/a9251eca
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/a9251eca

Branch: refs/heads/2.7.x-fixes
Commit: a9251eca76a2c883904cfae16e4311ce463b7c85
Parents: f74d764
Author: Akitoshi Yoshida <ay@apache.org>
Authored: Mon Feb 2 22:45:50 2015 +0100
Committer: Akitoshi Yoshida <ay@apache.org>
Committed: Mon Feb 2 22:45:50 2015 +0100

----------------------------------------------------------------------
 .../apache/cxf/feature/transform/XSLTUtils.java | 26 ++++++++++++++++++--
 1 file changed, 24 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/a9251eca/rt/core/src/main/java/org/apache/cxf/feature/transform/XSLTUtils.java
----------------------------------------------------------------------
diff --git a/rt/core/src/main/java/org/apache/cxf/feature/transform/XSLTUtils.java b/rt/core/src/main/java/org/apache/cxf/feature/transform/XSLTUtils.java
index 1488b5d..0f495ef 100644
--- a/rt/core/src/main/java/org/apache/cxf/feature/transform/XSLTUtils.java
+++ b/rt/core/src/main/java/org/apache/cxf/feature/transform/XSLTUtils.java
@@ -51,10 +51,10 @@ public final class XSLTUtils {
     }
 
     public static InputStream transform(Templates xsltTemplate, InputStream in) {
+        CachedOutputStream out = new CachedOutputStream();
         try {
             XMLStreamReader reader = StaxUtils.createXMLStreamReader(in);
             Source beforeSource = new StaxSource(reader);
-            CachedOutputStream out = new CachedOutputStream();
 
             Transformer trans = xsltTemplate.newTransformer();
             trans.transform(beforeSource, new StreamResult(out));
@@ -64,14 +64,25 @@ public final class XSLTUtils {
             throw new Fault("GET_CACHED_INPUT_STREAM", LOG, e, e.getMessage());
         } catch (TransformerException e) {
             throw new Fault("XML_TRANSFORM", LOG, e, e.getMessage());
+        } finally {
+            try {
+                in.close();
+            } catch (Exception e) {
+                // ignore
+            }
+            try {
+                out.close();
+            } catch (Exception e) {
+                // ignore
+            }
         }
     }
 
     public static Reader transform(Templates xsltTemplate, Reader inReader) {
+        CachedWriter outWriter = new CachedWriter();
         try {
             XMLStreamReader reader = StaxUtils.createXMLStreamReader(inReader);
             Source beforeSource = new StaxSource(reader);
-            CachedWriter outWriter = new CachedWriter();
 
             Transformer trans = xsltTemplate.newTransformer();
             trans.transform(beforeSource, new StreamResult(outWriter));
@@ -81,6 +92,17 @@ public final class XSLTUtils {
             throw new Fault("GET_CACHED_INPUT_STREAM", LOG, e, e.getMessage());
         } catch (TransformerException e) {
             throw new Fault("XML_TRANSFORM", LOG, e, e.getMessage());
+        } finally {
+            try {
+                inReader.close();
+            } catch (Exception e) {
+                // ignore
+            }
+            try {
+                outWriter.close();
+            } catch (Exception e) {
+                // ignore
+            }
         }
     }
 


Mime
View raw message