You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by pa...@apache.org on 2020/03/19 12:07:22 UTC
[groovy] 01/03: reduce SpotBugs warnings
This is an automated email from the ASF dual-hosted git repository.
paulk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/groovy.git
commit 7139b7b12df6011a068f0a021d25ba3f7e779dd3
Author: Paul King <pa...@asert.com.au>
AuthorDate: Thu Mar 19 21:47:37 2020 +1000
reduce SpotBugs warnings
---
.../src/main/java/org/codehaus/groovy/ant/Groovy.java | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/subprojects/groovy-ant/src/main/java/org/codehaus/groovy/ant/Groovy.java b/subprojects/groovy-ant/src/main/java/org/codehaus/groovy/ant/Groovy.java
index 73dbe0c..51896b2 100644
--- a/subprojects/groovy-ant/src/main/java/org/codehaus/groovy/ant/Groovy.java
+++ b/subprojects/groovy-ant/src/main/java/org/codehaus/groovy/ant/Groovy.java
@@ -24,6 +24,7 @@ import groovy.lang.GroovyClassLoader;
import groovy.lang.GroovyShell;
import groovy.lang.MissingMethodException;
import groovy.lang.Script;
+import groovy.util.CharsetToolkit;
import org.apache.groovy.io.StringBuilderWriter;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Project;
@@ -315,15 +316,14 @@ public class Groovy extends Java {
// if there are no groovy statements between the enclosing Groovy tags
// then read groovy statements in from a text file using the src attribute
if (command == null || command.trim().length() == 0) {
+ if (srcFile == null || !srcFile.exists()) {
+ throw new BuildException("Source file does not exist!", getLocation());
+ }
createClasspath().add(new Path(getProject(), srcFile.getParentFile().getCanonicalPath()));
- command = getText(new BufferedReader(new FileReader(srcFile)));
+ command = getText(new CharsetToolkit(srcFile).getReader());
}
- if (command != null) {
- execGroovy(command, out);
- } else {
- throw new BuildException("Source file does not exist!", getLocation());
- }
+ execGroovy(command, out);
} finally {
if (out != null && out != System.out) {