8251184: File association without description causes exception
Reviewed-by: asemenyuk, almatvee
This commit is contained in:
parent
77c46ea911
commit
e800cc2d2d
@ -79,11 +79,15 @@ final class FileAssociation {
|
||||
FileAssociation assoc = new FileAssociation();
|
||||
|
||||
assoc.launcherPath = Path.of(launcherName);
|
||||
assoc.description = FA_DESCRIPTION.fetchFrom(fa);
|
||||
assoc.description = Optional.ofNullable(
|
||||
FA_DESCRIPTION.fetchFrom(fa))
|
||||
.orElse(launcherName + " association");
|
||||
assoc.extensions = Optional.ofNullable(
|
||||
FA_EXTENSIONS.fetchFrom(fa)).orElse(Collections.emptyList());
|
||||
FA_EXTENSIONS.fetchFrom(fa))
|
||||
.orElse(Collections.emptyList());
|
||||
assoc.mimeTypes = Optional.ofNullable(
|
||||
FA_CONTENT_TYPE.fetchFrom(fa)).orElse(Collections.emptyList());
|
||||
FA_CONTENT_TYPE.fetchFrom(fa))
|
||||
.orElse(Collections.emptyList());
|
||||
|
||||
Path icon = FA_ICON.fetchFrom(fa);
|
||||
if (icon != null) {
|
||||
|
@ -338,8 +338,8 @@ class StandardBundlerParam<T> extends BundlerParamInfo<T> {
|
||||
new StandardBundlerParam<>(
|
||||
"fileAssociation.description",
|
||||
String.class,
|
||||
params -> APP_NAME.fetchFrom(params) + " Path",
|
||||
null
|
||||
p -> null,
|
||||
(s, p) -> s
|
||||
);
|
||||
|
||||
static final StandardBundlerParam<Path> FA_ICON =
|
||||
|
@ -38,9 +38,11 @@ final public class FileAssociations {
|
||||
private void createFile() {
|
||||
Map<String, String> entries = new HashMap<>(Map.of(
|
||||
"extension", suffixName,
|
||||
"mime-type", getMime(),
|
||||
"description", description
|
||||
"mime-type", getMime()
|
||||
));
|
||||
if (description != null) {
|
||||
entries.put("description", description);
|
||||
}
|
||||
if (icon != null) {
|
||||
if (TKit.isWindows()) {
|
||||
entries.put("icon", icon.toString().replace("\\", "/"));
|
||||
|
@ -29,6 +29,7 @@ import jdk.jpackage.test.PackageTest;
|
||||
import jdk.jpackage.test.PackageType;
|
||||
import jdk.jpackage.test.FileAssociations;
|
||||
import jdk.jpackage.test.Annotations.Test;
|
||||
import jdk.jpackage.test.Annotations.Parameter;
|
||||
|
||||
/**
|
||||
* Test --file-associations parameter. Output of the test should be
|
||||
@ -81,13 +82,19 @@ import jdk.jpackage.test.Annotations.Test;
|
||||
|
||||
public class FileAssociationsTest {
|
||||
@Test
|
||||
public static void test() {
|
||||
@Parameter("true")
|
||||
@Parameter("false")
|
||||
public static void test(boolean includeDescription) {
|
||||
PackageTest packageTest = new PackageTest();
|
||||
|
||||
// Not supported
|
||||
packageTest.excludeTypes(PackageType.MAC_DMG);
|
||||
|
||||
new FileAssociations("jptest1").applyTo(packageTest);
|
||||
FileAssociations fa = new FileAssociations("jptest1");
|
||||
if (!includeDescription) {
|
||||
fa.setDescription(null);
|
||||
}
|
||||
fa.applyTo(packageTest);
|
||||
|
||||
Path icon = TKit.TEST_SRC_ROOT.resolve(Path.of("resources", "icon"
|
||||
+ TKit.ICON_SUFFIX));
|
||||
|
Loading…
Reference in New Issue
Block a user