Repository: groovy
Updated Branches:
  refs/heads/GROOVY_2_5_X 863cfeed3 -> ea1b71a9b


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

Branch: refs/heads/GROOVY_2_5_X
Commit: ea1b71a9b64f454562eb6182ae74cc3cd7de528f
Parents: 863cfee
Author: sunlan <[email protected]>
Authored: Wed Dec 13 15:34:05 2017 +0800
Committer: sunlan <[email protected]>
Committed: Wed Dec 13 15:35:50 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/ea1b71a9/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