Skip to content
This repository has been archived by the owner on Sep 2, 2022. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
8269036: tools/jpackage/share/AppImagePackageTest.java failed with "h…
…diutil: create failed - Resource busy"

Reviewed-by: asemenyuk, herrick
  • Loading branch information
Alexander Matveev committed Jun 25, 2021
1 parent 5ebed06 commit fb0a95f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
Expand Up @@ -346,7 +346,11 @@ private Path buildDMG( Map<String, ? super Object> params,
"-volname", APP_NAME.fetchFrom(params),
"-ov", protoDMG.toAbsolutePath().toString(),
"-fs", "HFS+");
IOUtils.exec(pb, false, null, true, Executor.INFINITE_TIMEOUT);
new RetryExecutor()
.setMaxAttemptsCount(10)
.setAttemptTimeoutMillis(3000)
.setWriteOutputToFile(true)
.execute(pb);
}

// mount temp image
Expand Down
Expand Up @@ -32,6 +32,7 @@ public final class RetryExecutor {
public RetryExecutor() {
setMaxAttemptsCount(5);
setAttemptTimeoutMillis(2 * 1000);
setWriteOutputToFile(false);
}

public RetryExecutor setMaxAttemptsCount(int v) {
Expand All @@ -44,6 +45,11 @@ public RetryExecutor setAttemptTimeoutMillis(int v) {
return this;
}

RetryExecutor setWriteOutputToFile(boolean v) {
writeOutputToFile = v;
return this;
}

public RetryExecutor setExecutorInitializer(Consumer<Executor> v) {
executorInitializer = v;
return this;
Expand All @@ -69,11 +75,13 @@ static RetryExecutor retryOnKnownErrorMessage(String v) {
}

public void execute(String cmdline[]) throws IOException {
executeLoop(() -> Executor.of(cmdline));
executeLoop(() ->
Executor.of(cmdline).setWriteOutputToFile(writeOutputToFile));
}

public void execute(ProcessBuilder pb) throws IOException {
executeLoop(() -> Executor.of(pb));
executeLoop(() ->
Executor.of(pb).setWriteOutputToFile(writeOutputToFile));
}

private void executeLoop(Supplier<Executor> execSupplier) throws IOException {
Expand Down Expand Up @@ -109,4 +117,5 @@ private void executeLoop(Supplier<Executor> execSupplier) throws IOException {
private boolean aborted;
private int attempts;
private int timeoutMillis;
private boolean writeOutputToFile;
}

1 comment on commit fb0a95f

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.