8206962: jlink --release-info=del throws NPE if no keys are specified
Reviewed-by: alanb
--- a/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/ReleaseInfoPlugin.java Wed Dec 05 11:01:44 2018 +0100
+++ b/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/ReleaseInfoPlugin.java Wed Dec 05 19:22:04 2018 +0530
@@ -108,7 +108,11 @@
case "del": {
// --release-info del:keys=openjdk,java_version
- Utils.parseList(config.get(KEYS)).stream().forEach((k) -> {
+ String keys = config.get(KEYS);
+ if (keys == null || keys.isEmpty()) {
+ throw new IllegalArgumentException("No key specified for delete");
+ }
+ Utils.parseList(keys).stream().forEach((k) -> {
release.remove(k);
});
}
--- a/test/jdk/tools/jlink/JLinkTest.java Wed Dec 05 11:01:44 2018 +0100
+++ b/test/jdk/tools/jlink/JLinkTest.java Wed Dec 05 19:22:04 2018 +0530
@@ -44,6 +44,7 @@
* @summary Test image creation
* @bug 8189777
* @bug 8194922
+ * @bug 8206962
* @author Jean-Francois Denise
* @requires (vm.compMode != "Xcomp" & os.maxMemory >= 2g)
* @library ../lib
@@ -344,6 +345,16 @@
.option("--help")
.call().assertSuccess();
}
+
+ {
+ String imageDir = "bug8206962";
+ JImageGenerator.getJLinkTask()
+ .modulePath(helper.defaultModulePath())
+ .output(helper.createNewImageDir(imageDir))
+ .addMods("java.base")
+ .option("--release-info=del")
+ .call().assertFailure("Error: No key specified for delete");
+ }
}
private static void testCompress(Helper helper, String moduleName, String... userOptions) throws IOException {