Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8069211

(zipfs) ZipFileSystem creates corrupted zip if entry output stream gets closed more than once

XMLWordPrintable

    • b48
    • Verified

        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();
                }
            }
        }

              sherman Xueming Shen
              sherman Xueming Shen
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

                Created:
                Updated:
                Resolved: