groovy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jwagenleit...@apache.org
Subject groovy git commit: findbugs fix: close stream
Date Sun, 11 Sep 2016 06:53:21 GMT
Repository: groovy
Updated Branches:
  refs/heads/master a8fb77602 -> 3291eedee


findbugs fix: close stream


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

Branch: refs/heads/master
Commit: 3291eedee0c38782335e3455a2b103ff24a582a7
Parents: a8fb776
Author: John Wagenleitner <jwagenleitner@apache.org>
Authored: Sat Sep 10 23:35:48 2016 -0700
Committer: John Wagenleitner <jwagenleitner@apache.org>
Committed: Sat Sep 10 23:35:48 2016 -0700

----------------------------------------------------------------------
 src/main/org/codehaus/groovy/control/XStreamUtils.java | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/groovy/blob/3291eede/src/main/org/codehaus/groovy/control/XStreamUtils.java
----------------------------------------------------------------------
diff --git a/src/main/org/codehaus/groovy/control/XStreamUtils.java b/src/main/org/codehaus/groovy/control/XStreamUtils.java
index 609d7d2..3f7ccd3 100644
--- a/src/main/org/codehaus/groovy/control/XStreamUtils.java
+++ b/src/main/org/codehaus/groovy/control/XStreamUtils.java
@@ -20,6 +20,7 @@ package org.codehaus.groovy.control;
 
 import com.thoughtworks.xstream.XStream;
 import com.thoughtworks.xstream.io.xml.StaxDriver;
+import org.codehaus.groovy.runtime.DefaultGroovyMethods;
 
 import java.io.File;
 import java.io.FileWriter;
@@ -31,19 +32,22 @@ public abstract class XStreamUtils {
         if (name == null || name.length() == 0) return;
 
         XStream xstream = new XStream(new StaxDriver());
+        FileWriter astFileWriter = null;
         try {
             File astFile = astFile(name);
             if (astFile == null) {
                 System.out.println("File-name for writing " + name + " AST could not be determined!");
                 return;
             }
-
-            xstream.toXML(ast, new FileWriter(astFile, false));
+            astFileWriter = new FileWriter(astFile, false);
+            xstream.toXML(ast, astFileWriter);
             System.out.println("Written AST to " + name + ".xml");
 
         } catch (Exception e) {
             System.out.println("Couldn't write to " + name + ".xml");
             e.printStackTrace();
+        } finally {
+            DefaultGroovyMethods.closeQuietly(astFileWriter);
         }
     }
 


Mime
View raw message