After digging some more into the code of it, I've realized that the readFully() method is really hard to understand. So, unless there are some substantial performance gains in the existing approach, maybe we should go with something a bit simpler. And just as a side note, you've probably noticed that I've produced some simple code to replicate (alleged) JDK ZipFile bugs. Any feedback on the validity of that code would be welcome (ie. maybe I'm doing something really stupid in there). Bojan
--- /home/groups/devel/jakarta/jakarta-tomcat/src/share/org/apache/tomcat/util/depend/DependClassLoader.java Mon Sep 17 11:51:16 2001 +++ +jakarta-tomcat-changed/src/share/org/apache/tomcat/util/depend/DependClassLoader.java + Tue Sep 18 21:00:11 2001 @@ -263,32 +263,14 @@ return parent; } - private byte[] readFully( InputStream is ) - throws IOException + private byte[] readFully(InputStream is) + throws IOException { - byte b[]=new byte[1024]; - int count=0; + int b; + ByteArrayOutputStream buf=new ByteArrayOutputStream(); - int available=1024; - - while (true) { - int nRead = is.read(b,count,available); - if( nRead== -1 ) { - // we're done reading - byte result[]=new byte[count]; - System.arraycopy( b, 0, result, 0, count ); - return result; - } - // got a chunk - count += nRead; - available -= nRead; - if( available == 0 ) { - // buffer full - byte b1[]=new byte[ b.length * 2 ]; - available=b.length; - System.arraycopy( b, 0, b1, 0, b.length ); - b=b1; - } - } + while((b=is.read())!=-1) buf.write(b); + + return buf.toByteArray(); } }