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

jar leaves temporary file when exception occur in creating jar

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 9
    • 9
    • tools
    • None
    • jar
    • b160

        To reproduce the issue:

        mkdir a; touch test a/test
        jdk-9/bin/jar cf test.jar -C a test test

        Creating test.jar will fail (which is expected), but a temporary file be left behind.

        $ mkdir a; touch test a/test
        $ ls -l /tmp/test.jar*
        ls: cannot access /tmp/test.jar*: No such file or directory

        $ jdk-9/bin/jar cf test.jar -C a test test
        java.util.zip.ZipException: duplicate entry: test
        at java.base/java.util.zip.ZipOutputStream.putNextEntry(ZipOutputStream.java:231)
        at java.base/java.util.jar.JarOutputStream.putNextEntry(JarOutputStream.java:109)
        at jdk.jartool/sun.tools.jar.Main.addFile(Main.java:1179)
        at jdk.jartool/sun.tools.jar.Main.create(Main.java:849)
        at jdk.jartool/sun.tools.jar.Main.run(Main.java:308)
        at jdk.jartool/sun.tools.jar.Main.main(Main.java:1651)

        $ ls /tmp/test.jar*
        /tmp/test.jar16981332899083569432.jar

              sherman Xueming Shen
              amlu Amy Lu (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Created:
                Updated:
                Resolved: