Skip to content

Commit

Permalink
8272815: jpackage --type rpm produces an error: Invalid or unsupporte…
Browse files Browse the repository at this point in the history
…d type: [null]

Reviewed-by: asemenyuk
Backport-of: a3ca770227065aecc2df9f9c711687fd8ec5d34e
  • Loading branch information
GoeLin committed Jul 18, 2022
1 parent 4bab0eb commit 100c802
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 16 deletions.
24 changes: 11 additions & 13 deletions src/jdk.jpackage/share/classes/jdk/jpackage/internal/Arguments.java
Expand Up @@ -35,6 +35,7 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Properties;
import java.util.ResourceBundle;
import java.util.jar.Attributes;
Expand Down Expand Up @@ -635,15 +636,13 @@ private jdk.jpackage.internal.Bundler getPlatformBundler() {
for (jdk.jpackage.internal.Bundler bundler :
Bundlers.createBundlersInstance().getBundlers(bundleType)) {
if (type == null) {
if (bundler.isDefault()
&& bundler.supported(runtimeInstaller)) {
return bundler;
}
if (bundler.isDefault()) {
return bundler;
}
} else {
if ((appImage || type.equalsIgnoreCase(bundler.getID()))
&& bundler.supported(runtimeInstaller)) {
return bundler;
}
if (appImage || type.equalsIgnoreCase(bundler.getID())) {
return bundler;
}
}
}
return null;
Expand All @@ -652,8 +651,6 @@ private jdk.jpackage.internal.Bundler getPlatformBundler() {
private void generateBundle(Map<String,? super Object> params)
throws PackagerException {

boolean bundleCreated = false;

// the temp dir needs to be fetched from the params early,
// to prevent each copy of the params (such as may be used for
// additional launchers) from generating a separate temp dir when
Expand All @@ -665,9 +662,10 @@ private void generateBundle(Map<String,? super Object> params)
// determine what bundler to run
jdk.jpackage.internal.Bundler bundler = getPlatformBundler();

if (bundler == null) {
throw new PackagerException("ERR_InvalidInstallerType",
deployParams.getTargetFormat());
if (bundler == null || !bundler.supported(runtimeInstaller)) {
String type = Optional.ofNullable(bundler).map(Bundler::getID).orElseGet(
() -> deployParams.getTargetFormat());
throw new PackagerException("ERR_InvalidInstallerType", type);
}

Map<String, ? super Object> localParams = new HashMap<>(params);
Expand Down
Expand Up @@ -32,7 +32,7 @@

/*
* @test
* @summary jpackage application version testing
* @summary Test jpackage output for erroneous input
* @library ../../../../helpers
* @build jdk.jpackage.test.*
* @modules jdk.jpackage/jdk.jpackage.internal
Expand All @@ -44,7 +44,7 @@

/*
* @test
* @summary jpackage application version testing
* @summary Test jpackage output for erroneous input
* @library ../../../../helpers
* @build jdk.jpackage.test.*
* @modules jdk.jpackage/jdk.jpackage.internal
Expand Down Expand Up @@ -96,7 +96,7 @@ public static Collection input() {
{"Hello",
new String[]{"--type", "invalid-type"},
null,
"Invalid or unsupported type:"},
"Invalid or unsupported type: [invalid-type]"},
// no --input
{"Hello",
null,
Expand Down

1 comment on commit 100c802

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.