8226532: cleanup is not called when jpackage command fails. JDK-8200758-branch
authorherrick
Fri, 21 Jun 2019 10:14:49 -0400
branchJDK-8200758-branch
changeset 57421 0410ee319681
parent 57420 c84d7dc9e434
child 57438 4a31db8d42bd
8226532: cleanup is not called when jpackage command fails. Reviewed-by: kcr
src/jdk.jpackage/share/classes/jdk/jpackage/internal/Arguments.java
--- a/src/jdk.jpackage/share/classes/jdk/jpackage/internal/Arguments.java	Fri Jun 21 08:32:59 2019 -0400
+++ b/src/jdk.jpackage/share/classes/jdk/jpackage/internal/Arguments.java	Fri Jun 21 10:14:49 2019 -0400
@@ -627,9 +627,6 @@
         try {
             bundler.validate(localParams);
             File result = bundler.execute(localParams, deployParams.outdir);
-            if (!userProvidedBuildRoot) {
-                bundler.cleanup(localParams);
-            }
             if (result == null) {
                 throw new PackagerException("MSG_BundlerFailed",
                         bundler.getID(), bundler.getName());
@@ -660,6 +657,10 @@
                 Log.verbose(MessageFormat.format(
                         I18N.getString("message.debug-working-directory"),
                         (new File(buildRoot)).getAbsolutePath()));
+            } else {
+                // always clean up the temporary directory created
+                // when --temp-root option not used.
+                bundler.cleanup(localParams);
             }
         }
     }