diff --git a/gc/gc-base/src/main/java/org/projectnessie/gc/expire/local/DefaultLocalExpire.java b/gc/gc-base/src/main/java/org/projectnessie/gc/expire/local/DefaultLocalExpire.java index 587d53e7f3d..3ad0e2842eb 100644 --- a/gc/gc-base/src/main/java/org/projectnessie/gc/expire/local/DefaultLocalExpire.java +++ b/gc/gc-base/src/main/java/org/projectnessie/gc/expire/local/DefaultLocalExpire.java @@ -67,15 +67,10 @@ public DeleteSummary expire() { Instant started = clock().instant(); expireParameters().liveContentSet().startExpireContents(started); - ForkJoinPool forkJoinPool = null; + ForkJoinPool forkJoinPool = new ForkJoinPool(parallelism()); try { - DeleteSummary deleteSummary; - if (parallelism() == 1) { - deleteSummary = this.expireContents(); - } else { - forkJoinPool = new ForkJoinPool(parallelism()); - deleteSummary = forkJoinPool.invoke(ForkJoinTask.adapt(this::expireContents)); - } + DeleteSummary deleteSummary = + forkJoinPool.invoke(ForkJoinTask.adapt(this::expireInForkJoinPool)); LOGGER.info( "live-set#{}: Expiry finished, took {}, deletion summary: {}.", expireParameters().liveContentSet().id(), @@ -84,13 +79,11 @@ public DeleteSummary expire() { return deleteSummary; } finally { expireParameters().liveContentSet().finishedExpireContents(clock().instant(), null); - if (forkJoinPool != null) { - forkJoinPool.shutdown(); - } + forkJoinPool.shutdown(); } } - private DeleteSummary expireContents() { + private DeleteSummary expireInForkJoinPool() { try (Stream contentIds = expireParameters().liveContentSet().fetchContentIds()) { return contentIds .parallel() diff --git a/gc/gc-base/src/main/java/org/projectnessie/gc/identify/IdentifyLiveContents.java b/gc/gc-base/src/main/java/org/projectnessie/gc/identify/IdentifyLiveContents.java index f57406f1b5e..6688c843bf9 100644 --- a/gc/gc-base/src/main/java/org/projectnessie/gc/identify/IdentifyLiveContents.java +++ b/gc/gc-base/src/main/java/org/projectnessie/gc/identify/IdentifyLiveContents.java @@ -163,10 +163,6 @@ public UUID identifyLiveContents() { throw new IllegalStateException("identifyLiveContents() has already been called."); } - if (parallelism() == 1) { - return this.walkAllReferences(); - } - ForkJoinPool forkJoinPool = new ForkJoinPool(parallelism()); try { return forkJoinPool.invoke(ForkJoinTask.adapt(this::walkAllReferences));