Skip to content

Commit

Permalink
async IntegrationTestUploadStarter that does not block the app from s…
Browse files Browse the repository at this point in the history
…tarting
  • Loading branch information
ylexus committed Jun 30, 2021
1 parent 11ead21 commit c2fe112
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Optional;
import java.util.concurrent.ForkJoinPool;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicReference;

Expand Down Expand Up @@ -47,14 +48,14 @@ public static void forgetUploadStateOnShutdown() {

@Override
protected void doStart() {
uploader.upload(ImmutableList.of(rootDir), resume)
ForkJoinPool.commonPool().execute(() -> uploader.upload(ImmutableList.of(rootDir), resume)
.whenComplete(logErrorOnFailure(logger, "Failed"))
.whenComplete((aVoid, throwable) -> {
lastFailure.set(throwable);
if (forgetUploadStateOnShutdown.getAndSet(false)) {
uploader.forgetUploadState();
}
applicationLifecycleControl.initiateShutdown();
});
}));
}
}

0 comments on commit c2fe112

Please sign in to comment.