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 16:38:31 GMT
Repository: cxf
Updated Branches:
  refs/heads/master 51996bbc5 -> ade3480bf


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

Branch: refs/heads/master
Commit: ade3480bf2d4af2346c0d72b36f7e5cdbdc77e95
Parents: 51996bb
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 17:37:49 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/ade3480b/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