diff --git a/WHATSNEW b/WHATSNEW index f3032b4c8..5b2bff393 100644 --- a/WHATSNEW +++ b/WHATSNEW @@ -114,7 +114,10 @@ Fixed bugs: behaved identically. * now sets the context classloader if you've specified a nested - . Bugzilla report 24802. + . Bugzilla Report 24802. + +* and friends would delete the original file when trying to update + a read-only archive. Bugzilla Report 28419. Other changes: -------------- diff --git a/src/main/org/apache/tools/ant/taskdefs/Zip.java b/src/main/org/apache/tools/ant/taskdefs/Zip.java index e29a0c4e1..be3cfdd84 100644 --- a/src/main/org/apache/tools/ant/taskdefs/Zip.java +++ b/src/main/org/apache/tools/ant/taskdefs/Zip.java @@ -338,6 +338,14 @@ public class Zip extends MatchingTask { + archiveType + " file to create!"); } + if (zipFile.exists() && !zipFile.isFile()) { + throw new BuildException(zipFile + " is not a file."); + } + + if (zipFile.exists() && !zipFile.canWrite()) { + throw new BuildException(zipFile + " is read-only."); + } + // Renamed version of original file, if it exists File renamedFile = null; // Whether or not an actual update is required -