Repository: groovy Updated Branches: refs/heads/master 6a8518dbf -> e6db31177
Minor refactoring Project: http://git-wip-us.apache.org/repos/asf/groovy/repo Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/e6db3117 Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/e6db3117 Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/e6db3117 Branch: refs/heads/master Commit: e6db31177e1d34a3f472d4922bd1ee582e00ac1a Parents: 6a8518d Author: sunlan <[email protected]> Authored: Sun Sep 17 04:47:53 2017 +0800 Committer: sunlan <[email protected]> Committed: Sun Sep 17 04:47:53 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/e6db3117/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 - } - } - } } /**
