-
Bug
-
Resolution: Duplicate
-
P3
-
None
-
8u251
-
x86
-
linux
ADDITIONAL SYSTEM INFORMATION :
reproduces on:
OpenJDK Runtime Environment (build 1.8.0_252-b09)/Linux x86_64
OpenJDK Runtime Environment (AdoptOpenJDK)(build 1.8.0_252-b09)/Linux x86_64
Java(TM) SE Runtime Environment (build 1.8.0_251-b08)/Linux x86_64
does not reproduce on:
OpenJDK Runtime Environment (AdoptOpenJDK)(build 1.8.0_232-b09)/Linux x86_64
A DESCRIPTION OF THE PROBLEM :
It seems that changes introduced inJDK-8232003 lead to two successive calls of com.sun.nio.zipfs.ZipFileSystem.EntryOutputStream#close() method which in turn leads to creation of empty zip file entries.
REGRESSION : Last worked in version 8
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
~]$ javac ZipFilesWrite.java
~]$ java -ea -cp . ZipFilesWrite
~]$ echo $?
0
ACTUAL -
~]$ java -ea -cp . ZipFilesWrite
Exception in thread "main" java.lang.AssertionError
at ZipFilesWrite.main(ZipFilesWrite.java:28)
~]$ echo $?
1
---------- BEGIN SOURCE ----------
import java.io.FileOutputStream;
import java.net.URI;
import java.nio.file.*;
import java.util.Collections;
import java.util.HashMap;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
import java.util.zip.ZipOutputStream;
public class ZipFilesWrite {
public static void main(String[] args) throws Exception {
Path zip = null;
try {
zip = Files.createTempFile("8232003", ".zip");
try (ZipOutputStream out = new ZipOutputStream(new FileOutputStream(zip.toFile()))) {
}
URI uri = URI.create("jar:file:" + zip.toUri().getPath().replace(" ", "%20"));
try (FileSystem fileSystem = FileSystems.newFileSystem(uri, new HashMap<>())) {
Path root = fileSystem.getRootDirectories().iterator().next();
Path manifest = root.resolve("test.txt");
Files.write(manifest, Collections.singletonList("Main-Class: " + ZipFilesWrite.class), StandardOpenOption.WRITE,
StandardOpenOption.TRUNCATE_EXISTING, StandardOpenOption.CREATE);
}
ZipFile zipFile = new ZipFile(zip.toFile());
ZipEntry zipEntry = zipFile.getEntry("test.txt");
assert zipEntry.getSize() > 0;
} finally {
if (zip != null) {
Files.deleteIfExists(zip);
}
}
}
}
---------- END SOURCE ----------
FREQUENCY : always
reproduces on:
OpenJDK Runtime Environment (build 1.8.0_252-b09)/Linux x86_64
OpenJDK Runtime Environment (AdoptOpenJDK)(build 1.8.0_252-b09)/Linux x86_64
Java(TM) SE Runtime Environment (build 1.8.0_251-b08)/Linux x86_64
does not reproduce on:
OpenJDK Runtime Environment (AdoptOpenJDK)(build 1.8.0_232-b09)/Linux x86_64
A DESCRIPTION OF THE PROBLEM :
It seems that changes introduced in
REGRESSION : Last worked in version 8
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
~]$ javac ZipFilesWrite.java
~]$ java -ea -cp . ZipFilesWrite
~]$ echo $?
0
ACTUAL -
~]$ java -ea -cp . ZipFilesWrite
Exception in thread "main" java.lang.AssertionError
at ZipFilesWrite.main(ZipFilesWrite.java:28)
~]$ echo $?
1
---------- BEGIN SOURCE ----------
import java.io.FileOutputStream;
import java.net.URI;
import java.nio.file.*;
import java.util.Collections;
import java.util.HashMap;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
import java.util.zip.ZipOutputStream;
public class ZipFilesWrite {
public static void main(String[] args) throws Exception {
Path zip = null;
try {
zip = Files.createTempFile("8232003", ".zip");
try (ZipOutputStream out = new ZipOutputStream(new FileOutputStream(zip.toFile()))) {
}
URI uri = URI.create("jar:file:" + zip.toUri().getPath().replace(" ", "%20"));
try (FileSystem fileSystem = FileSystems.newFileSystem(uri, new HashMap<>())) {
Path root = fileSystem.getRootDirectories().iterator().next();
Path manifest = root.resolve("test.txt");
Files.write(manifest, Collections.singletonList("Main-Class: " + ZipFilesWrite.class), StandardOpenOption.WRITE,
StandardOpenOption.TRUNCATE_EXISTING, StandardOpenOption.CREATE);
}
ZipFile zipFile = new ZipFile(zip.toFile());
ZipEntry zipEntry = zipFile.getEntry("test.txt");
assert zipEntry.getSize() > 0;
} finally {
if (zip != null) {
Files.deleteIfExists(zip);
}
}
}
}
---------- END SOURCE ----------
FREQUENCY : always
- duplicates
-
JDK-8069211 (zipfs) ZipFileSystem creates corrupted zip if entry output stream gets closed more than once
- Closed