You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by bu...@apache.org on 2015/02/04 09:49:00 UTC
[Bug 57533] New: NullPointerException FileUtil.rename ResourceUtils
when copyUsingFileChannels fails
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: notifications@ant.apache.org
Reporter: tst2011@gmx.de
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.
[Bug 57533] NullPointerException FileUtil.rename /
ResourceUtils.copyFile() if copyUsingFileChannels failed
Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=57533
Thomas Stroeter <ts...@gmx.de> changed:
What |Removed |Added
----------------------------------------------------------------------------
Summary|NullPointerException |NullPointerException
|FileUtil.rename |FileUtil.rename /
|ResourceUtils when |ResourceUtils.copyFile() if
|copyUsingFileChannels fails |copyUsingFileChannels
| |failed
OS| |All
--
You are receiving this mail because:
You are the assignee for the bug.
[Bug 57533] NullPointerException FileUtil.rename /
ResourceUtils.copyFile() if copyUsingFileChannels failed
Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=57533
Stefan Bodewig <bo...@apache.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution|--- |FIXED
Target Milestone|--- |1.9.5
--- Comment #1 from Stefan Bodewig <bo...@apache.org> ---
This is a situation that probably doesn't happen too often - source and target
location of rename are on different file systems and an IOException occurs
while copying. Still it's strange it hasn't been reported before. Thanks!
git commit dc37a17
--
You are receiving this mail because:
You are the assignee for the bug.