You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by su...@apache.org on 2017/12/08 03:39:57 UTC
groovy git commit: Close reader
Repository: groovy
Updated Branches:
refs/heads/master bc69ec968 -> 384ee1c44
Close reader
Project: http://git-wip-us.apache.org/repos/asf/groovy/repo
Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/384ee1c4
Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/384ee1c4
Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/384ee1c4
Branch: refs/heads/master
Commit: 384ee1c44b1b64719503395f8c80bfd62284eeea
Parents: bc69ec9
Author: sunlan <su...@apache.org>
Authored: Fri Dec 8 11:39:51 2017 +0800
Committer: sunlan <su...@apache.org>
Committed: Fri Dec 8 11:39:51 2017 +0800
----------------------------------------------------------------------
.../groovy/tools/LoaderConfiguration.java | 66 +++++++++++---------
1 file changed, 35 insertions(+), 31 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/groovy/blob/384ee1c4/src/main/org/codehaus/groovy/tools/LoaderConfiguration.java
----------------------------------------------------------------------
diff --git a/src/main/org/codehaus/groovy/tools/LoaderConfiguration.java b/src/main/org/codehaus/groovy/tools/LoaderConfiguration.java
index 6b9da28..4124ddb 100644
--- a/src/main/org/codehaus/groovy/tools/LoaderConfiguration.java
+++ b/src/main/org/codehaus/groovy/tools/LoaderConfiguration.java
@@ -105,38 +105,42 @@ public class LoaderConfiguration {
*/
public void configure(InputStream is) throws IOException {
BufferedReader reader = new BufferedReader(new InputStreamReader(is));
- int lineNumber = 0;
-
- while (true) {
- String line = reader.readLine();
- if (line == null) break;
-
- line = line.trim();
- lineNumber++;
-
- if (line.startsWith("#") || line.length() == 0) continue;
-
- if (line.startsWith(LOAD_PREFIX)) {
- String loadPath = line.substring(LOAD_PREFIX.length()).trim();
- loadPath = assignProperties(loadPath);
- loadFilteredPath(loadPath);
- } else if (line.startsWith(GRAB_PREFIX)) {
- String grabParams = line.substring(GRAB_PREFIX.length()).trim();
- grabList.add(assignProperties(grabParams));
- } else if (line.startsWith(MAIN_PREFIX)) {
- if (main != null)
- throw new IOException("duplicate definition of main in line " + lineNumber + " : " + line);
- main = line.substring(MAIN_PREFIX.length()).trim();
- } else if (line.startsWith(PROP_PREFIX)) {
- String params = line.substring(PROP_PREFIX.length()).trim();
- String key = SystemUtil.setSystemPropertyFrom(params);
- System.setProperty(key, assignProperties(System.getProperty(key)));
- } else if (line.startsWith(CONFIGSCRIPT_PREFIX)) {
- String script = line.substring(CONFIGSCRIPT_PREFIX.length()).trim();
- configScripts.add(assignProperties(script));
- } else {
- throw new IOException("unexpected line in " + lineNumber + " : " + line);
+ try {
+ int lineNumber = 0;
+
+ while (true) {
+ String line = reader.readLine();
+ if (line == null) break;
+
+ line = line.trim();
+ lineNumber++;
+
+ if (line.startsWith("#") || line.length() == 0) continue;
+
+ if (line.startsWith(LOAD_PREFIX)) {
+ String loadPath = line.substring(LOAD_PREFIX.length()).trim();
+ loadPath = assignProperties(loadPath);
+ loadFilteredPath(loadPath);
+ } else if (line.startsWith(GRAB_PREFIX)) {
+ String grabParams = line.substring(GRAB_PREFIX.length()).trim();
+ grabList.add(assignProperties(grabParams));
+ } else if (line.startsWith(MAIN_PREFIX)) {
+ if (main != null)
+ throw new IOException("duplicate definition of main in line " + lineNumber + " : " + line);
+ main = line.substring(MAIN_PREFIX.length()).trim();
+ } else if (line.startsWith(PROP_PREFIX)) {
+ String params = line.substring(PROP_PREFIX.length()).trim();
+ String key = SystemUtil.setSystemPropertyFrom(params);
+ System.setProperty(key, assignProperties(System.getProperty(key)));
+ } else if (line.startsWith(CONFIGSCRIPT_PREFIX)) {
+ String script = line.substring(CONFIGSCRIPT_PREFIX.length()).trim();
+ configScripts.add(assignProperties(script));
+ } else {
+ throw new IOException("unexpected line in " + lineNumber + " : " + line);
+ }
}
+ } finally {
+ reader.close();
}
if (requireMain && main == null) throw new IOException("missing main class definition in config file");