groovy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jwagenleit...@apache.org
Subject [1/2] groovy git commit: findbugs fix: close stream
Date Sun, 11 Sep 2016 20:46:20 GMT
Repository: groovy
Updated Branches:
  refs/heads/GROOVY_2_4_X 9c6960978 -> a691f510a


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/288134df
Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/288134df
Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/288134df

Branch: refs/heads/GROOVY_2_4_X
Commit: 288134df0d3d497d62f0733550d4e80388beda44
Parents: 9c69609
Author: John Wagenleitner <jwagenleitner@apache.org>
Authored: Sat Sep 10 23:35:48 2016 -0700
Committer: John Wagenleitner <jwagenleitner@apache.org>
Committed: Sun Sep 11 12:56:00 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/288134df/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