This is an automated email from the ASF dual-hosted git repository.
daim pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/jackrabbit-oak.git
The following commit(s) were added to refs/heads/trunk by this push:
new d2ecbc95b8 OAK-11919 : removed usage of Guava's ListenableFutureTask
from prod files (#2627)
d2ecbc95b8 is described below
commit d2ecbc95b8d23c0416810a95452b84c1d88335e0
Author: Rishabh Kumar <[email protected]>
AuthorDate: Thu Nov 27 16:41:04 2025 +0530
OAK-11919 : removed usage of Guava's ListenableFutureTask from prod files
(#2627)
---
.../plugins/blob/MarkSweepGarbageCollector.java | 14 ++++++++----
.../index/elastic/ElasticIndexStatistics.java | 26 ++++++++++++++++------
2 files changed, 29 insertions(+), 11 deletions(-)
diff --git
a/oak-blob-plugins/src/main/java/org/apache/jackrabbit/oak/plugins/blob/MarkSweepGarbageCollector.java
b/oak-blob-plugins/src/main/java/org/apache/jackrabbit/oak/plugins/blob/MarkSweepGarbageCollector.java
index 1f95901dc0..7015baab07 100644
---
a/oak-blob-plugins/src/main/java/org/apache/jackrabbit/oak/plugins/blob/MarkSweepGarbageCollector.java
+++
b/oak-blob-plugins/src/main/java/org/apache/jackrabbit/oak/plugins/blob/MarkSweepGarbageCollector.java
@@ -47,6 +47,8 @@ import java.util.Map;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.Callable;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.CompletionException;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Executor;
import java.util.concurrent.TimeUnit;
@@ -57,7 +59,6 @@ import java.util.stream.Collectors;
import org.apache.commons.collections4.ListValuedMap;
import org.apache.commons.collections4.multimap.ArrayListValuedHashMap;
import org.apache.commons.io.IOUtils;
-import org.apache.jackrabbit.guava.common.util.concurrent.ListenableFutureTask;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.LineIterator;
import org.apache.jackrabbit.core.data.DataRecord;
@@ -730,9 +731,14 @@ public class MarkSweepGarbageCollector implements
BlobGarbageCollector {
if (!markOnly) {
// Find all blobs available in the blob store
- ListenableFutureTask<Integer> blobIdRetriever =
ListenableFutureTask.create(new BlobIdRetriever(fs,
- true));
- executor.execute(blobIdRetriever);
+ CompletableFuture<Integer> blobIdRetriever =
CompletableFuture.supplyAsync(() -> {
+ try {
+ return new BlobIdRetriever(fs, true).call();
+ } catch (Exception e) {
+ throw new CompletionException(e);
+ }
+ }, executor);
+
try {
blobIdRetriever.get();
diff --git
a/oak-search-elastic/src/main/java/org/apache/jackrabbit/oak/plugins/index/elastic/ElasticIndexStatistics.java
b/oak-search-elastic/src/main/java/org/apache/jackrabbit/oak/plugins/index/elastic/ElasticIndexStatistics.java
index 8cd016f0f2..f963eb504b 100644
---
a/oak-search-elastic/src/main/java/org/apache/jackrabbit/oak/plugins/index/elastic/ElasticIndexStatistics.java
+++
b/oak-search-elastic/src/main/java/org/apache/jackrabbit/oak/plugins/index/elastic/ElasticIndexStatistics.java
@@ -20,6 +20,8 @@ import java.io.IOException;
import java.time.Clock;
import java.util.List;
import java.util.Objects;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.CompletionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
@@ -29,6 +31,7 @@ import
co.elastic.clients.elasticsearch._types.query_dsl.Query;
import org.apache.commons.lang3.concurrent.BasicThreadFactory;
import org.apache.jackrabbit.guava.common.base.Ticker;
+import org.apache.jackrabbit.oak.commons.internal.concurrent.FutureConverter;
import org.apache.jackrabbit.oak.plugins.index.elastic.util.ElasticIndexUtils;
import org.apache.jackrabbit.oak.plugins.index.search.IndexStatistics;
import org.jetbrains.annotations.NotNull;
@@ -39,7 +42,6 @@ import org.apache.jackrabbit.guava.common.cache.CacheBuilder;
import org.apache.jackrabbit.guava.common.cache.CacheLoader;
import org.apache.jackrabbit.guava.common.cache.LoadingCache;
import org.apache.jackrabbit.guava.common.util.concurrent.ListenableFuture;
-import org.apache.jackrabbit.guava.common.util.concurrent.ListenableFutureTask;
import co.elastic.clients.elasticsearch._types.Bytes;
import co.elastic.clients.elasticsearch.cat.indices.IndicesRecord;
@@ -219,9 +221,14 @@ public class ElasticIndexStatistics implements
IndexStatistics {
@Override
public @NotNull ListenableFuture<Integer> reload(@NotNull
StatsRequestDescriptor crd, @NotNull Integer oldValue) {
- ListenableFutureTask<Integer> task =
ListenableFutureTask.create(() -> count(crd));
- REFRESH_EXECUTOR.execute(task);
- return task;
+ CompletableFuture<Integer> task = CompletableFuture.supplyAsync(()
-> {
+ try {
+ return count(crd);
+ } catch (IOException e) {
+ throw new CompletionException(e);
+ }
+ }, REFRESH_EXECUTOR);
+ return FutureConverter.toListenableFuture(task);
}
private int count(StatsRequestDescriptor crd) throws IOException {
@@ -247,9 +254,14 @@ public class ElasticIndexStatistics implements
IndexStatistics {
@Override
public @NotNull ListenableFuture<StatsResponse> reload(@NotNull
StatsRequestDescriptor crd, @NotNull StatsResponse oldValue) {
- ListenableFutureTask<StatsResponse> task =
ListenableFutureTask.create(() -> stats(crd));
- REFRESH_EXECUTOR.execute(task);
- return task;
+ CompletableFuture<StatsResponse> task =
CompletableFuture.supplyAsync(() -> {
+ try {
+ return stats(crd);
+ } catch (IOException e) {
+ throw new CompletionException(e);
+ }
+ }, REFRESH_EXECUTOR);
+ return FutureConverter.toListenableFuture(task);
}
private StatsResponse stats(StatsRequestDescriptor crd) throws
IOException {