groovy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sun...@apache.org
Subject groovy git commit: Minor refactoring
Date Sat, 16 Sep 2017 20:48:42 GMT
Repository: groovy
Updated Branches:
  refs/heads/GROOVY_2_6_X 995479cd5 -> 7ba35700e


Minor refactoring

(cherry picked from commit e6db311)


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

Branch: refs/heads/GROOVY_2_6_X
Commit: 7ba35700e618611d017cc4ea7bec7e6c4fb7d345
Parents: 995479c
Author: sunlan <sunlan@apache.org>
Authored: Sun Sep 17 04:47:53 2017 +0800
Committer: sunlan <sunlan@apache.org>
Committed: Sun Sep 17 04:48:35 2017 +0800

----------------------------------------------------------------------
 .../org/codehaus/groovy/control/SourceUnit.java | 21 ++------------------
 1 file changed, 2 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/groovy/blob/7ba35700/src/main/org/codehaus/groovy/control/SourceUnit.java
----------------------------------------------------------------------
diff --git a/src/main/org/codehaus/groovy/control/SourceUnit.java b/src/main/org/codehaus/groovy/control/SourceUnit.java
index 2dcb82a..8f3ce5e 100644
--- a/src/main/org/codehaus/groovy/control/SourceUnit.java
+++ b/src/main/org/codehaus/groovy/control/SourceUnit.java
@@ -223,31 +223,14 @@ public class SourceUnit extends ProcessingUnit {
         //
         // Create a reader on the source and run the parser.
 
-        Reader reader = null;
-        try {
-            reader = source.getReader();
-
+        try (Reader reader = source.getReader()) {
             // let's recreate the parser each time as it tends to keep around state
             parserPlugin = getConfiguration().getPluginFactory().createParserPlugin();
 
             cst = parserPlugin.parseCST(this, reader);
-
-            reader.close();
-
-        }
-        catch (IOException e) {
+        } catch (IOException e) {
             getErrorCollector().addFatalError(new SimpleMessage(e.getMessage(), this));
         }
-        finally {
-            if (reader != null) {
-                try {
-                    reader.close();
-                }
-                catch (IOException e) {
-                    // Ignore
-                }
-            }
-        }
     }
 
     /**


Mime
View raw message