Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files
8251184: File association without description causes exception
Reviewed-by: asemenyuk, almatvee
  • Loading branch information
Andy Herrick committed Aug 7, 2020
1 parent 18fdf05 commit 6f3d6865e8193bfe592ae17e555eecd018da9d42
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 9 deletions.
@@ -79,11 +79,15 @@ static List<FileAssociation> fetchFrom(Map<String, ? super Object> params) {
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 @@
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 @@ public FileAssociations(String faSuffixName) {
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.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 @@

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));

0 comments on commit 6f3d686

Please sign in to comment.