0

I save several files in a zip file using Java's FileSystem. If there is not enough disk space I can not get java.io.IOException No space left on device and it behaves as if the zip file were created successfully.

Here is a snippet from my project:

Path pathToZip = Paths.get("path/to/existing/zip");

try(FileSystem fs = FileSystems.newFileSystem(pathToZip, null)) {
    // zip some files via
    Path pathToSomeFile = Paths.get("path/of/some/file/to/be/zipped");
    Files.copy(pathToSomeFile, fs.getPath("/path/of/some/file/to/be/zipped"));
} catch (IOException ex) {
    log.error("error on zipping files", ex);
}

The FileSystems.newFileSystem(pathToZip, null) creates a ZipFileSystem instance. I've debugged up to the method sync() of the class ZipFileSystem. Then, when the java.io.IOException No space left on device occurs, only x.printStackTrace() is called and the exception is gone.

What options do I have to see if the file was successfully written?

Karsten R
  • 9
  • 3
  • File a bug report. Catching such exceptions and proceeding with corrupted data definitely is a bug. – Holger Jun 06 '19 at 17:03
  • 1
    Thanks. I have just created a bug report. Once it has passed the review process, I will post the link here. – Karsten R Jun 07 '19 at 08:39
  • 1
    The assigned Bug ID is JDK-8225507. The issue is visible at the following url [JDK-8225507](https://bugs.java.com/bugdatabase/view_bug.do?bug_id=JDK-8225507). – Karsten R Jul 08 '19 at 07:43

0 Answers0