Repository: groovy
Updated Branches:
  refs/heads/GROOVY_2_6_X f79639740 -> 636bf2192


Trivial refactoring

(cherry picked from commit 084a398)


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

Branch: refs/heads/GROOVY_2_6_X
Commit: 636bf2192a8af649e14ca33b63e22ce17e7f0754
Parents: f796397
Author: sunlan <[email protected]>
Authored: Wed Dec 13 15:34:05 2017 +0800
Committer: sunlan <[email protected]>
Committed: Wed Dec 13 15:35:08 2017 +0800

----------------------------------------------------------------------
 src/main/org/codehaus/groovy/tools/DgmConverter.java | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/groovy/blob/636bf219/src/main/org/codehaus/groovy/tools/DgmConverter.java
----------------------------------------------------------------------
diff --git a/src/main/org/codehaus/groovy/tools/DgmConverter.java 
b/src/main/org/codehaus/groovy/tools/DgmConverter.java
index ba714bb..f733227 100644
--- a/src/main/org/codehaus/groovy/tools/DgmConverter.java
+++ b/src/main/org/codehaus/groovy/tools/DgmConverter.java
@@ -93,12 +93,14 @@ public class DgmConverter implements Opcodes {
             cw.visitEnd();
 
             final byte[] bytes = cw.toByteArray();
+
             File targetFile = new File(targetDirectory + className + 
".class").getCanonicalFile();
             targetFile.getParentFile().mkdirs();
-            final FileOutputStream fileOutputStream = new 
FileOutputStream(targetFile);
-            fileOutputStream.write(bytes);
-            fileOutputStream.flush();
-            fileOutputStream.close();
+
+            try (final FileOutputStream fileOutputStream = new 
FileOutputStream(targetFile)) {
+                fileOutputStream.write(bytes);
+                fileOutputStream.flush();
+            }
         }
 
         GeneratedMetaMethod.DgmMethodRecord.saveDgmInfo(records, 
targetDirectory+"/META-INF/dgminfo");

Reply via email to