FULL PRODUCT VERSION :
java version "1.5.0_07"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_07-b03)
Java HotSpot(TM) Client VM (build 1.5.0_07-b03, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
Windows XP, Windows 2000
A DESCRIPTION OF THE PROBLEM :
A simple one entry ZipOutputStream is dramatically slower in 1.5.0_07 to the point of being unusable for even modest sized arrays.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
See the attached code.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Here are previous JVM / OS combinations(size is bytes, time is seconds):
1.3.1_01 Win XP
size: 1000 time: 0.078
size: 10000 time: 0.0
size: 100000 time: 0.016
size: 1000000 time: 0.282
size: 10000000 time: 1.016
size: 20971520 time: 2.094
1.4.2_07 WIN 2000
size: 1000 time: 0.02
size: 10000 time: 0.0
size: 100000 time: 0.01
size: 1000000 time: 0.22
size: 10000000 time: 1.492
size: 20971520 time: 3.095
1.4.2_12 WIN XP
size: 1000 time: 0.109
size: 10000 time: 0.0
size: 100000 time: 0.016
size: 1000000 time: 0.203
size: 10000000 time: 1.782
size: 20971520 time: 4.125
1.5.0_02 WIN XP
size: 1000 time: 0.078
size: 10000 time: 0.0
size: 100000 time: 0.031
size: 1000000 time: 0.234
size: 10000000 time: 1.718
size: 20971520 time: 3.484
1.5.0_06 WIN 2000
size: 1000 time: 0.01
size: 10000 time: 0.01
size: 100000 time: 0.02
size: 1000000 time: 0.241
size: 10000000 time: 1.522
size: 20971520 time: 3.375
ACTUAL -
Here are the timings for _07
1.5.0_07 Win XP
size: 1000 time: 0.0
size: 10000 time: 0.016
size: 100000 time: 0.031
size: 1000000 time: 1.813
size: 10000000 time: 251.661
size: 20971520 time: 1148.644
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
package test;
import java.io.*;
import java.util.Random;
import java.util.zip.*;
public class TestZip {
/**
* @param args
*/
public static void main(String[] args) {
try {
int[] sizes = new int[]{1000,10000,100000,1000000,10000000, 1024*1024*20};
Random r = new Random(System.currentTimeMillis());
for(int i=0;i<sizes.length;i++){
byte[] arr = new byte[sizes[i]];
r.nextBytes(arr);
//System.out.println("Beginning next round: " + arr.length);
long start =System.currentTimeMillis();
byte[] result = zipInputStream2("test", arr,1);
System.out.println("size: " + arr.length + " time: " + ((System.currentTimeMillis() - start)/1000.));
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public static byte[] zipInputStream2(String entryName, byte[] arr, int level) throws IOException {
ByteArrayOutputStream myOut = new ByteArrayOutputStream();
ZipOutputStream zipOut = new ZipOutputStream(myOut);
// zipOut.setLevel(level);
zipOut.putNextEntry(new ZipEntry(entryName));
zipOut.write(arr);
zipOut.closeEntry();
zipOut.close();
return myOut.toByteArray();
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Rolling back to 1.5.0_02
Release Regression From : 5.0u6
The above release value was the last known release where this
bug was not reproducible. Since then there has been a regression.