Browse Source

Work around a bug in Kaffe - we can as well label it "optimization" 8-)

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@271222 13f79535-47bb-0310-9956-ffa450edef68
master
Stefan Bodewig 23 years ago
parent
commit
750999053f
2 changed files with 15 additions and 5 deletions
  1. +3
    -3
      src/main/org/apache/tools/ant/taskdefs/Zip.java
  2. +12
    -2
      src/main/org/apache/tools/zip/ZipOutputStream.java

+ 3
- 3
src/main/org/apache/tools/ant/taskdefs/Zip.java View File

@@ -351,8 +351,8 @@ public class Zip extends MatchingTask {
}
}
}
} catch (IOException ioe) {
String msg = "Problem creating " + archiveType + ": " + ioe.getMessage();
} catch (Throwable t) {
String msg = "Problem creating " + archiveType + ": " + t.getMessage();

// delete a bogus ZIP file
if (!zipFile.delete()) {
@@ -366,7 +366,7 @@ public class Zip extends MatchingTask {
}
}

throw new BuildException(msg, ioe, location);
throw new BuildException(msg, t, location);
} finally {
cleanUp();
}


+ 12
- 2
src/main/org/apache/tools/zip/ZipOutputStream.java View File

@@ -1,7 +1,7 @@
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* Copyright (c) 2001-2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -105,6 +105,14 @@ public class ZipOutputStream extends DeflaterOutputStream {
*/
private int level = Deflater.DEFAULT_COMPRESSION;

/**
* Has the compression level changed when compared to the last
* entry?
*
* @since 1.5
*/
private boolean hasCompressionLevelChanged = false;

/**
* Default compression method for next entry.
*
@@ -331,8 +339,9 @@ public class ZipOutputStream extends DeflaterOutputStream {
throw new ZipException("crc checksum is required for STORED method");
}
entry.setComprSize(entry.getSize());
} else {
} else if (hasCompressionLevelChanged) {
def.setLevel(level);
hasCompressionLevelChanged = false;
}
writeLocalFileHeader(entry);
}
@@ -354,6 +363,7 @@ public class ZipOutputStream extends DeflaterOutputStream {
* @since 1.1
*/
public void setLevel(int level) {
hasCompressionLevelChanged = (this.level != level);
this.level = level;
}



Loading…
Cancel
Save