ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Earl Hood <>
Subject ZipOutputStream exception in Ant 1.9.5 and 1.9.6
Date Mon, 20 Jul 2015 20:56:42 GMT
It appears the zip problems have not been fully fixed in Ant.

I have a program that uses Ant's ZipOutputStream class, and it has had
no problems with versions of Ant 1.9.4 and earlier.  However, with Ant
1.9.5 and 1.9.6, I get the following exception:

    at java.lang.System.arraycopy(Native Method)
    at com.pbmassoc.nsiv.util.ZipDMs.zipFlattenDMs(
    at com.pbmassoc.nsiv.util.ZipDMs.main(

The following is the code block that uses ZipOutputStream.  There are
some application-specific calls in it, but I figure they are fairly
easy to understand what they do:

  public static void zipFlattenDMs(
      File outZip,
      File dir
  ) throws IOException {
    List<File> files = NSIVUtil.getDMFiles(dir);
    ZipOutputStream out = null;
    try {
      // We use apache tools (Ant) ZipOutputStream.
      out = new ZipOutputStream(outZip);
      for (File f : files) {
        String basename = f.getName();
        if (!FileUtil.isXml(basename) ||
            (!basename.startsWith(DMC_PREFIX) &&
             !basename.startsWith(DME_PREFIX))) {
        String dmcBase   = S1000DUtil.extractDMCBase(basename);
        String entryName = dmcBase + ".xml";
        ZipEntry e       = new ZipEntry(entryName);
        NSIVUtil.sendFile(f, out);
    } finally {
      if (out != null) {

Exception is thrown when calling the close() method on `out' in the
finally block.

As a test, I modified the above code to use Java's version of
ZipOutputStream, and I received no errors.  The change is basically
modifying the constructor call as follows:

      out = new ZipOutputStream(new FileOutputStream(outZip));

And importing Java's classes and not Ant's (this includes using Java's
ZipEntry classs).

I may be able to live with using the Java library implementation of the
zip classes, but it does raise some concerns about the robustness of the
Ant's zip-related tasks, which we use in various Ant build files.  The
testing I have performed with our project has shown no other problems.

I am guessing the following work noted in the release notes:

 * ported some of the write-optimization of Commons Compress 1.10 to
   the ZIP package

introduced regression bugs, bugs that have not been fully flushed out,
or detected.

Any guidance appreciated,


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message