8245311: [macos] misc package tests failed due to "execution error: Finder got an error: AppleEvent timed out."

Reviewed-by: herrick, asemenyuk
This commit is contained in:
Alexander Matveev 2020-07-22 14:19:01 -07:00
parent a764279daa
commit f8a06bc497
2 changed files with 16 additions and 2 deletions

View File

@ -443,7 +443,12 @@ public class MacDmgBundler extends MacBaseInstallerBundler {
"-force",
hdiUtilVerbosityFlag,
mountedRoot.toAbsolutePath().toString());
IOUtils.exec(pb);
// "hdiutil detach" might not work right away due to resource busy error, so
// repeat detach several times.
RetryExecutor retryExecutor = new RetryExecutor();
// 10 times with 3 second delays.
retryExecutor.setMaxAttemptsCount(10).setAttemptTimeoutMillis(3000)
.execute(pb);
}
// Compress it to a new image

View File

@ -26,6 +26,7 @@ package jdk.incubator.jpackage.internal;
import java.io.IOException;
import java.util.function.Consumer;
import java.util.function.Supplier;
public final class RetryExecutor {
RetryExecutor() {
@ -64,10 +65,18 @@ public final class RetryExecutor {
}
void execute(String cmdline[]) throws IOException {
executeLoop(() -> Executor.of(cmdline));
}
void execute(ProcessBuilder pb) throws IOException {
executeLoop(() -> Executor.of(pb));
}
private void executeLoop(Supplier<Executor> execSupplier) throws IOException {
aborted = false;
for (;;) {
try {
Executor exec = Executor.of(cmdline);
Executor exec = execSupplier.get();
if (executorInitializer != null) {
executorInitializer.accept(exec);
}