This is the mail archive of the java@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

PR 8234: ZipInputStream chokes when InputStream.read() returns small chunks


Conclusive proof that java.util.zip is broken.

import java.io.*;
import java.net.*;
import java.util.zip.*;
public class test {
    public static void main(String[] s) throws Exception {
        InputStream is = new URL(" http://www.megacz.com/gcj-bug.zip";).openStream();
        ZipInputStream zis = new ZipInputStream(new FilterInputStream(is) {
                public int read(byte[] b, int off, int len) throws IOException {
                    int ret = 0;
                    if (len > 32) len = 32;
                    while (len > 0) {
                        int read = super.read(b, off, len);
                        if (read == -1) break;
                        ret += read;
                        len -= read;
                        off += read;
                    }
                    return ret;
                }
            });
        while(zis.getNextEntry() != null) { }
    }
}

  - a

-- 
"Through your rags I see your vanity"  -- Socrates


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]