Repository: groovy
Updated Branches:
  refs/heads/GROOVY_2_5_X 46f0416f6 -> 799b853dd


Minor refactoring

(cherry picked from commit e6db31177e1d34a3f472d4922bd1ee582e00ac1a)


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

Branch: refs/heads/GROOVY_2_5_X
Commit: 799b853dd80d341d85ff11eb8da155613957447e
Parents: 46f0416
Author: sunlan <[email protected]>
Authored: Sun Sep 17 04:51:45 2017 +0800
Committer: sunlan <[email protected]>
Committed: Sun Sep 17 04:51:45 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/799b853d/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 b2c8a32..9a1727d 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
-                }
-            }
-        }
     }
 
     /**

Reply via email to