Bug with the zip fs provider (7u72, 8u25), am able to create a corrupted zip...

Francis Galiegue fgaliegue at gmail.com
Fri Jan 16 17:10:03 UTC 2015


OK, I have a more simple reproducer:

public final class Jsr203ZipBug
{
    public static void main(final String... args)
        throws IOException
    {
        final Path zipPath
            = Paths.get(System.getProperty("java.io.tmpdir"), "t.zip");
        Files.deleteIfExists(zipPath);

        final URI uri = URI.create("jar:" + zipPath.toUri());

        final Map<String, ?> env = Collections.singletonMap("create", "true");

        try (
            final FileSystem zipfs = FileSystems.newFileSystem(uri, env);
            final OutputStream out
                = Files.newOutputStream(zipfs.getPath("/foo"));
        ) {
            out.write("hello".getBytes());
            out.close();
        }
    }
}

Note that it doesn't matter whether I also .flush() before I close.

-- 
Francis Galiegue, fgaliegue at gmail.com, https://github.com/fge
JSON Schema in Java: http://json-schema-validator.herokuapp.com
Parsers in pure Java: https://github.com/parboiled1/grappa (redde
Caesaris: https://github.com/sirthias)


More information about the nio-dev mailing list