Skip to content
Permalink
Browse files
8267056: tools/jpackage/share/RuntimePackageTest.java fails with NoSu…
…chFileException

Reviewed-by: asemenyuk, herrick
  • Loading branch information
Alexander Matveev committed May 21, 2021
1 parent e094f3f commit 9eaa4afc99b09f4704e4d641f95104be40b9ea66
Showing with 15 additions and 10 deletions.
  1. +14 −10 src/jdk.jpackage/macosx/classes/jdk/jpackage/internal/MacPkgBundler.java
  2. +1 −0 test/jdk/tools/jpackage/share/RuntimePackageTest.java
@@ -390,16 +390,20 @@ private String getRoot(Map<String, ? super Object> params,
Path rootDir = appLocation.getParent() == null ?
Path.of(".") : appLocation.getParent();

Path[] list = Files.list(rootDir).toArray(Path[]::new);
if (list != null) { // Should not happend
// We should only have app image and/or .DS_Store
if (list.length == 1) {
return rootDir.toString();
} else if (list.length == 2) {
// Check case with app image and .DS_Store
if (list[0].toString().toLowerCase().endsWith(".ds_store") ||
list[1].toString().toLowerCase().endsWith(".ds_store")) {
return rootDir.toString(); // Only app image and .DS_Store
// Not needed for runtime installer and it might break runtime installer
// if parent does not have any other files
if (!StandardBundlerParam.isRuntimeInstaller(params)) {
try (var fileList = Files.list(rootDir)) {
Path[] list = fileList.toArray(Path[]::new);
// We should only have app image and/or .DS_Store
if (list.length == 1) {
return rootDir.toString();
} else if (list.length == 2) {
// Check case with app image and .DS_Store
if (list[0].toString().toLowerCase().endsWith(".ds_store") ||
list[1].toString().toLowerCase().endsWith(".ds_store")) {
return rootDir.toString(); // Only app image and .DS_Store
}
}
}
}
@@ -151,6 +151,7 @@ private static PackageTest init(Set<PackageType> types) {
final Path prefsDir = Path.of(".systemPrefs");
return files.map(root::relativize)
.filter(x -> !x.startsWith(prefsDir))
.filter(x -> !x.endsWith(".DS_Store"))
.collect(Collectors.toSet());
}
}

0 comments on commit 9eaa4af

Please sign in to comment.