https://issues.apache.org/bugzilla/show_bug.cgi?id=57533
Bug ID: 57533
Summary: NullPointerException FileUtil.rename ResourceUtils
when copyUsingFileChannels fails
Product: Ant
Version: 1.9.4
Hardware: PC
Status: NEW
Severity: normal
Priority: P2
Component: Core
Assignee: [email protected]
Reporter: [email protected]
Ant scripts are failing time by time because of a NPE (see stacktrace below).
looking at the sourcecode (ResourceUtils.java line:439) a null-reference for
"project" must be the culprit:
a)
try {
copyUsingFileChannels(sourceFile, destFile);
copied = true;
} catch (IOException ex) {
project.log("Attempt to copy " + sourceFile
+ " to " + destFile + " using NIO Channels"
+ " failed due to '" + ex.getMessage()
+ "'. Falling back to streams.",
Project.MSG_WARN);
}
b) It would also crash in the streamCopy-fallback at the second location with a
NPE because auf procect=null
at line 439:
private static OutputStream getOutputStream(Resource resource, boolean
append, Project project)
throws IOException {
if (append) {
Appendable a = resource.as(Appendable.class);
if (a != null) {
return a.getAppendOutputStream();
}
project.log("Appendable OutputStream not available for
non-appendable resource "
+ resource + "; using plain OutputStream",
Project.MSG_VERBOSE);
}
return resource.getOutputStream();
}
Guess it would be worth fixing in the next release :->
Schlauberger Spruch am Ende: and a good NPE-checker of the IDE should have
detected this, too :->
//////////////////////////////////////////////////////////////////////////
STACKTRACE:
(project=null is set in FileUtils.java line 409)
java.lang.NullPointerException
at org.apache.tools.ant.util.ResourceUtils.copyResource(ResourceUtils.java
line:439)
at org.apache.tools.ant.util.FileUtils.copyFile(FileUtils.java line:559)
at org.apache.tools.ant.util.FileUtils.copyFile(FileUtils.java line:519)
at org.apache.tools.ant.util.FileUtils.copyFile(FileUtils.java line:480)
at org.apache.tools.ant.util.FileUtils.copyFile(FileUtils.java line:443)
at org.apache.tools.ant.util.FileUtils.copyFile(FileUtils.java line:409)
at org.apache.tools.ant.util.FileUtils.copyFile(FileUtils.java line:384)
at org.apache.tools.ant.util.FileUtils.copyFile(FileUtils.java line:322)
at org.apache.tools.ant.util.FileUtils.rename(FileUtils.java line:1317)
at org.apache.tools.ant.taskdefs.Replace.processFile(Replace.java line:691)
at org.apache.tools.ant.taskdefs.Replace.execute(Replace.java line:530)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java
line:292)
--
You are receiving this mail because:
You are the assignee for the bug.