Browse Source

NullPointerException in ResourceUtils.copyUsingFileChannels

Bugzilla Report 57533
master
Stefan Bodewig 10 years ago
parent
commit
dc37a17ff8
2 changed files with 22 additions and 7 deletions
  1. +6
    -0
      WHATSNEW
  2. +16
    -7
      src/main/org/apache/tools/ant/util/ResourceUtils.java

+ 6
- 0
WHATSNEW View File

@@ -64,6 +64,12 @@ Fixed bugs:
archive failed.
Port of https://issues.apache.org/jira/browse/COMPRESS-297

* FileUtils.rename which is used by several tasks can throw a
NullPointerException if the "normal" renameTo operation fails and
an exception occurs while rename falls back to copying and deleting
the file.
Bugzilla Report 57533

Other changes:
--------------



+ 16
- 7
src/main/org/apache/tools/ant/util/ResourceUtils.java View File

@@ -435,11 +435,15 @@ public class ResourceUtils {
copyUsingFileChannels(sourceFile, destFile);
copied = true;
} catch (final 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);
String msg = "Attempt to copy " + sourceFile
+ " to " + destFile + " using NIO Channels"
+ " failed due to '" + ex.getMessage()
+ "'. Falling back to streams.";
if (project != null) {
project.log(msg, Project.MSG_WARN);
} else {
System.err.println(msg);
}
}
}
if (!copied) {
@@ -828,8 +832,13 @@ public class ResourceUtils {
if (a != null) {
return a.getAppendOutputStream();
}
project.log("Appendable OutputStream not available for non-appendable resource "
+ resource + "; using plain OutputStream", Project.MSG_VERBOSE);
String msg = "Appendable OutputStream not available for non-appendable resource "
+ resource + "; using plain OutputStream";
if (project != null) {
project.log(msg, Project.MSG_VERBOSE);
} else {
System.out.println(msg);
}
}
return resource.getOutputStream();
}


Loading…
Cancel
Save