Skip to content

Commit 9eaa4af

Browse files
author
Alexander Matveev
committed
8267056: tools/jpackage/share/RuntimePackageTest.java fails with NoSuchFileException
Reviewed-by: asemenyuk, herrick
1 parent e094f3f commit 9eaa4af

File tree

2 files changed

+15
-10
lines changed

2 files changed

+15
-10
lines changed

src/jdk.jpackage/macosx/classes/jdk/jpackage/internal/MacPkgBundler.java

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -390,16 +390,20 @@ private String getRoot(Map<String, ? super Object> params,
390390
Path rootDir = appLocation.getParent() == null ?
391391
Path.of(".") : appLocation.getParent();
392392

393-
Path[] list = Files.list(rootDir).toArray(Path[]::new);
394-
if (list != null) { // Should not happend
395-
// We should only have app image and/or .DS_Store
396-
if (list.length == 1) {
397-
return rootDir.toString();
398-
} else if (list.length == 2) {
399-
// Check case with app image and .DS_Store
400-
if (list[0].toString().toLowerCase().endsWith(".ds_store") ||
401-
list[1].toString().toLowerCase().endsWith(".ds_store")) {
402-
return rootDir.toString(); // Only app image and .DS_Store
393+
// Not needed for runtime installer and it might break runtime installer
394+
// if parent does not have any other files
395+
if (!StandardBundlerParam.isRuntimeInstaller(params)) {
396+
try (var fileList = Files.list(rootDir)) {
397+
Path[] list = fileList.toArray(Path[]::new);
398+
// We should only have app image and/or .DS_Store
399+
if (list.length == 1) {
400+
return rootDir.toString();
401+
} else if (list.length == 2) {
402+
// Check case with app image and .DS_Store
403+
if (list[0].toString().toLowerCase().endsWith(".ds_store") ||
404+
list[1].toString().toLowerCase().endsWith(".ds_store")) {
405+
return rootDir.toString(); // Only app image and .DS_Store
406+
}
403407
}
404408
}
405409
}

test/jdk/tools/jpackage/share/RuntimePackageTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ private static Set<Path> listFiles(Path root) throws IOException {
151151
final Path prefsDir = Path.of(".systemPrefs");
152152
return files.map(root::relativize)
153153
.filter(x -> !x.startsWith(prefsDir))
154+
.filter(x -> !x.endsWith(".DS_Store"))
154155
.collect(Collectors.toSet());
155156
}
156157
}

0 commit comments

Comments
 (0)