jar --validate may lead to java.nio.file.FileAlreadyExistsException

XMLWordPrintable

    • Type: Bug
    • Resolution: Fixed
    • Priority: P4
    • 25
    • Affects Version/s: 17
    • Component/s: tools
    • None
    • jar
    • b03

      When the "jar --validate" command is run as follows:

      cat $JAVA_HOME/lib/jrt-fs.jar | jar --validate

      then it leads to the following exception:

      java.nio.file.FileAlreadyExistsException: /tmp/tmpJar128144111130442323.jar
      at java.base/sun.nio.fs.UnixException.translateToIOException(UnixException.java:94)
      at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:106)
      at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:111)
      at java.base/sun.nio.fs.UnixFileSystemProvider.newByteChannel(UnixFileSystemProvider.java:262)
      at java.base/java.nio.file.spi.FileSystemProvider.newOutputStream(FileSystemProvider.java:482)
      at java.base/java.nio.file.Files.newOutputStream(Files.java:228)
      at java.base/java.nio.file.Files.copy(Files.java:3164)
      at jdk.jartool/sun.tools.jar.Main.run(Main.java:430)
      at jdk.jartool/sun.tools.jar.Main.main(Main.java:1708)

      This is due to an oversight in the implementation of the validate option, where "Files.copy(in, file.toPath())" is called on an already existing (just generated temporary) target file.

            Assignee:
            Jaikiran Pai
            Reporter:
            Jaikiran Pai
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: