This is an automated email from the ASF dual-hosted git repository.

paulk pushed a commit to branch GROOVY_3_0_X
in repository https://gitbox.apache.org/repos/asf/groovy.git

commit eb58d01c9adf37c819e7eecaa14cef7468dbc451
Author: Paul King <[email protected]>
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) {

Reply via email to