8250646: hdiutil detach fix JDK-8245311 still fails sometimes
Reviewed-by: herrick, asemenyuk
This commit is contained in:
parent
36b129fe84
commit
45c4d9d519
@ -446,9 +446,22 @@ public class MacDmgBundler extends MacBaseInstallerBundler {
|
|||||||
// "hdiutil detach" might not work right away due to resource busy error, so
|
// "hdiutil detach" might not work right away due to resource busy error, so
|
||||||
// repeat detach several times.
|
// repeat detach several times.
|
||||||
RetryExecutor retryExecutor = new RetryExecutor();
|
RetryExecutor retryExecutor = new RetryExecutor();
|
||||||
// 10 times with 3 second delays.
|
// Image can get detach even if we got resource busy error, so stop
|
||||||
retryExecutor.setMaxAttemptsCount(10).setAttemptTimeoutMillis(3000)
|
// trying to detach it if it is no longer attached.
|
||||||
.execute(pb);
|
retryExecutor.setExecutorInitializer(exec -> {
|
||||||
|
if (!Files.exists(mountedRoot)) {
|
||||||
|
retryExecutor.abort();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
try {
|
||||||
|
// 10 times with 3 second delays.
|
||||||
|
retryExecutor.setMaxAttemptsCount(10).setAttemptTimeoutMillis(3000)
|
||||||
|
.execute(pb);
|
||||||
|
} catch (IOException ex) {
|
||||||
|
if (!retryExecutor.isAborted()) {
|
||||||
|
throw ex;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Compress it to a new image
|
// Compress it to a new image
|
||||||
|
@ -53,6 +53,10 @@ public final class RetryExecutor {
|
|||||||
aborted = true;
|
aborted = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
boolean isAborted() {
|
||||||
|
return aborted;
|
||||||
|
}
|
||||||
|
|
||||||
static RetryExecutor retryOnKnownErrorMessage(String v) {
|
static RetryExecutor retryOnKnownErrorMessage(String v) {
|
||||||
RetryExecutor result = new RetryExecutor();
|
RetryExecutor result = new RetryExecutor();
|
||||||
return result.setExecutorInitializer(exec -> {
|
return result.setExecutorInitializer(exec -> {
|
||||||
@ -75,6 +79,10 @@ public final class RetryExecutor {
|
|||||||
private void executeLoop(Supplier<Executor> execSupplier) throws IOException {
|
private void executeLoop(Supplier<Executor> execSupplier) throws IOException {
|
||||||
aborted = false;
|
aborted = false;
|
||||||
for (;;) {
|
for (;;) {
|
||||||
|
if (aborted) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Executor exec = execSupplier.get();
|
Executor exec = execSupplier.get();
|
||||||
if (executorInitializer != null) {
|
if (executorInitializer != null) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user