Browse Source

Fall back to stream based copy if channel based copy fails for some reason - PRs 53102 and 54397

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@1557433 13f79535-47bb-0310-9956-ffa450edef68
master
Stefan Bodewig 11 years ago
parent
commit
0c41850a54
1 changed files with 19 additions and 6 deletions
  1. +19
    -6
      src/main/org/apache/tools/ant/util/ResourceUtils.java

+ 19
- 6
src/main/org/apache/tools/ant/util/ResourceUtils.java View File

@@ -426,13 +426,26 @@ public class ResourceUtils {
filterChainsAvailable, append,
effectiveInputEncoding,
outputEncoding, project);
} else if (source.as(FileProvider.class) != null
&& destFile != null && !append) {
File sourceFile =
source.as(FileProvider.class).getFile();
copyUsingFileChannels(sourceFile, destFile);
} else {
copyUsingStreams(source, dest, append, project);
boolean copied = false;
if (source.as(FileProvider.class) != null
&& destFile != null && !append) {
File sourceFile =
source.as(FileProvider.class).getFile();
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);
}
}
if (!copied) {
copyUsingStreams(source, dest, append, project);
}
}
if (preserveLastModified) {
Touchable t = dest.as(Touchable.class);


Loading…
Cancel
Save