cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a.@apache.org
Subject cxf git commit: [CXF-6228] Using XSLTFeature with large messages creates unremovable temporary files
Date Mon, 02 Feb 2015 17:11:34 GMT
Repository: cxf
Updated Branches:
  refs/heads/3.0.x-fixes 8170b3ecb -> d565a483e


[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/d565a483
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/d565a483
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/d565a483

Branch: refs/heads/3.0.x-fixes
Commit: d565a483e829037f342e273a286ef574eaa73990
Parents: 8170b3e
Author: Akitoshi Yoshida <ay@apache.org>
Authored: Mon Feb 2 17:37:49 2015 +0100
Committer: Akitoshi Yoshida <ay@apache.org>
Committed: Mon Feb 2 18:01:09 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/d565a483/core/src/main/java/org/apache/cxf/feature/transform/XSLTUtils.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/cxf/feature/transform/XSLTUtils.java b/core/src/main/java/org/apache/cxf/feature/transform/XSLTUtils.java
index 1488b5d..0f495ef 100644
--- a/core/src/main/java/org/apache/cxf/feature/transform/XSLTUtils.java
+++ b/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