8373105: Test tools/jpackage/share/AsyncTest.java failed: problem running hdiutil

Reviewed-by: asemenyuk
This commit is contained in:
Alexander Matveev 2025-12-19 23:19:27 +00:00
parent 0a70da46f6
commit 2d09284060

View File

@ -81,12 +81,18 @@ public final class MacHelper {
ThrowingConsumer<Path, ? extends Exception> consumer) {
cmd.verifyIsOfType(PackageType.MAC_DMG);
// Mount DMG under random temporary folder to avoid collisions when
// mounting DMG with same name asynchroniusly multiple times.
// See JDK-8373105. "hdiutil" does not handle such cases very good.
final var mountRoot = TKit.createTempDirectory("mountRoot");
// Explode DMG assuming this can require interaction, thus use `yes`.
String attachCMD[] = {
"sh", "-c",
String.join(" ", "yes", "|", "/usr/bin/hdiutil", "attach",
JPackageCommand.escapeAndJoin(
cmd.outputBundle().toString()), "-plist")};
JPackageCommand.escapeAndJoin(cmd.outputBundle().toString()),
"-mountroot", PathUtils.normalizedAbsolutePathString(mountRoot),
"-nobrowse", "-plist")};
RetryExecutor attachExecutor = new RetryExecutor();
try {
// 10 times with 6 second delays.