Repository: groovy
Updated Branches:
  refs/heads/master 2b7e15249 -> 084a39835


Trivial refactoring


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

Branch: refs/heads/master
Commit: 084a39835c5cfd9bc7aff250f2b7df691cbf37f4
Parents: 2b7e152
Author: sunlan <[email protected]>
Authored: Wed Dec 13 15:34:05 2017 +0800
Committer: sunlan <[email protected]>
Committed: Wed Dec 13 15:34:16 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/084a3983/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