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 242eb7868e OAK-12032 : replaced guava's UncheckedExecutionException
with runtimeexception (#2650)
242eb7868e is described below
commit 242eb7868eb98169b8f8ed517a43adad82102f59
Author: Rishabh Kumar <[email protected]>
AuthorDate: Fri Dec 5 19:41:08 2025 +0530
OAK-12032 : replaced guava's UncheckedExecutionException with
runtimeexception (#2650)
---
.../jackrabbit/oak/benchmark/ReplicaCrashResilienceTest.java | 4 ++--
.../main/java/org/apache/jackrabbit/oak/cache/CacheLIRS.java | 7 +++----
.../org/apache/jackrabbit/oak/segment/file/FileStore.java | 3 +--
.../apache/jackrabbit/oak/segment/file/ReadOnlyFileStore.java | 3 +--
.../jackrabbit/oak/plugins/document/DocumentNodeStore.java | 11 ++---------
.../oak/plugins/document/DocumentNodeStoreService.java | 7 +++----
.../oak/plugins/document/mongo/MongoDocumentStore.java | 5 +----
7 files changed, 13 insertions(+), 27 deletions(-)
diff --git
a/oak-benchmarks/src/main/java/org/apache/jackrabbit/oak/benchmark/ReplicaCrashResilienceTest.java
b/oak-benchmarks/src/main/java/org/apache/jackrabbit/oak/benchmark/ReplicaCrashResilienceTest.java
index 26f73c3135..2be681ba43 100644
---
a/oak-benchmarks/src/main/java/org/apache/jackrabbit/oak/benchmark/ReplicaCrashResilienceTest.java
+++
b/oak-benchmarks/src/main/java/org/apache/jackrabbit/oak/benchmark/ReplicaCrashResilienceTest.java
@@ -112,7 +112,7 @@ public class ReplicaCrashResilienceTest extends Benchmark {
writerInfosNode.setProperty(LEVEL1POINTER,
level1Pointer);
writerInfosNode.setProperty(LEVEL2POINTER,
level2Pointer);
session.save();
- } catch
(org.apache.jackrabbit.guava.common.util.concurrent.UncheckedExecutionException
e) {
+ } catch (RuntimeException e) {
System.out.println("Got an UncheckedException (levels:
" + level1Pointer + "/" + level2Pointer
+ ") from the google cache probably: " + e);
try {
@@ -202,7 +202,7 @@ public class ReplicaCrashResilienceTest extends Benchmark {
System.out.println("Reader: verified
level1="+level1+", level2="+level2);
}
- } catch
(org.apache.jackrabbit.guava.common.util.concurrent.UncheckedExecutionException
e) {
+ } catch (RuntimeException e) {
System.out.println("Got an UncheckedException from
the google cache probably: " + e);
try {
Thread.sleep(500);
diff --git
a/oak-core-spi/src/main/java/org/apache/jackrabbit/oak/cache/CacheLIRS.java
b/oak-core-spi/src/main/java/org/apache/jackrabbit/oak/cache/CacheLIRS.java
index d5429a441a..e41a1daacf 100644
--- a/oak-core-spi/src/main/java/org/apache/jackrabbit/oak/cache/CacheLIRS.java
+++ b/oak-core-spi/src/main/java/org/apache/jackrabbit/oak/cache/CacheLIRS.java
@@ -38,7 +38,6 @@ import org.apache.jackrabbit.guava.common.cache.RemovalCause;
import org.apache.jackrabbit.guava.common.cache.Weigher;
import org.apache.jackrabbit.guava.common.collect.ImmutableMap;
import org.apache.jackrabbit.guava.common.util.concurrent.ListenableFuture;
-import
org.apache.jackrabbit.guava.common.util.concurrent.UncheckedExecutionException;
import org.apache.jackrabbit.oak.commons.annotations.Internal;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -294,19 +293,19 @@ public class CacheLIRS<K, V> implements LoadingCache<K,
V> {
/**
* Get the value, loading it if needed.
* <p>
- * If there is an exception loading, an UncheckedExecutionException is
+ * If there is an exception loading, an RuntimeException is
* thrown.
*
* @param key the key
* @return the value
- * @throws UncheckedExecutionException
+ * @throws RuntimeException
*/
@Override
public V getUnchecked(K key) {
try {
return get(key);
} catch (ExecutionException e) {
- throw new UncheckedExecutionException(e);
+ throw new RuntimeException(e);
}
}
diff --git
a/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/file/FileStore.java
b/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/file/FileStore.java
index 01776478b6..1f4bdc1f38 100644
---
a/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/file/FileStore.java
+++
b/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/file/FileStore.java
@@ -36,7 +36,6 @@ import java.util.concurrent.atomic.AtomicBoolean;
import java.util.function.Consumer;
import java.util.function.Supplier;
-import
org.apache.jackrabbit.guava.common.util.concurrent.UncheckedExecutionException;
import org.apache.jackrabbit.oak.commons.Buffer;
import org.apache.jackrabbit.oak.commons.pio.Closer;
import org.apache.jackrabbit.oak.segment.RecordId;
@@ -517,7 +516,7 @@ public class FileStore extends AbstractFileStore {
public Segment readSegment(final SegmentId id) {
try (ShutDownCloser ignored = shutDown.keepAlive()) {
return segmentCache.getSegment(id, () -> readSegmentUncached(id));
- } catch (ExecutionException | UncheckedExecutionException e) {
+ } catch (ExecutionException | RuntimeException e) {
if (e.getCause() instanceof RepositoryNotReachableException) {
RepositoryNotReachableException re =
(RepositoryNotReachableException) e.getCause();
log.warn("Unable to access repository", re);
diff --git
a/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/file/ReadOnlyFileStore.java
b/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/file/ReadOnlyFileStore.java
index a74e1a4f0d..a3ecf5f221 100644
---
a/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/file/ReadOnlyFileStore.java
+++
b/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/file/ReadOnlyFileStore.java
@@ -31,7 +31,6 @@ import java.util.concurrent.ExecutionException;
import java.util.function.Consumer;
import org.apache.jackrabbit.oak.commons.pio.Closer;
-import
org.apache.jackrabbit.guava.common.util.concurrent.UncheckedExecutionException;
import org.apache.jackrabbit.oak.segment.RecordId;
import org.apache.jackrabbit.oak.segment.Segment;
import org.apache.jackrabbit.oak.segment.SegmentId;
@@ -125,7 +124,7 @@ public class ReadOnlyFileStore extends AbstractFileStore {
public Segment readSegment(final SegmentId id) {
try {
return segmentCache.getSegment(id, () -> readSegmentUncached(id));
- } catch (ExecutionException | UncheckedExecutionException e) {
+ } catch (ExecutionException | RuntimeException e) {
throw asSegmentNotFoundException(e, id);
}
}
diff --git
a/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStore.java
b/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStore.java
index 5bc96c08f8..ef537564dd 100644
---
a/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStore.java
+++
b/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStore.java
@@ -75,7 +75,6 @@ import javax.jcr.PropertyType;
import org.apache.commons.lang3.StringUtils;
import org.apache.jackrabbit.guava.common.cache.Cache;
-import
org.apache.jackrabbit.guava.common.util.concurrent.UncheckedExecutionException;
import org.apache.jackrabbit.oak.api.Blob;
import org.apache.jackrabbit.oak.api.CommitFailedException;
import org.apache.jackrabbit.oak.api.PropertyState;
@@ -1413,9 +1412,7 @@ public final class DocumentNodeStore
|| node.equals(missing) ? null : node;
PERFLOG.end(start, 1, "getNode: path={}, rev={}", path, rev);
return result;
- } catch (UncheckedExecutionException e) {
- throw DocumentStoreException.convert(e.getCause());
- } catch (ExecutionException e) {
+ } catch (RuntimeException | ExecutionException e) {
throw DocumentStoreException.convert(e.getCause());
}
}
@@ -1474,11 +1471,7 @@ public final class DocumentNodeStore
nodeChildrenCache.put(key, children);
}
return children;
- } catch (UncheckedExecutionException e) {
- throw DocumentStoreException.convert(e.getCause(),
- "Error occurred while fetching children for path "
- + path);
- } catch (ExecutionException e) {
+ } catch (RuntimeException | ExecutionException e) {
throw DocumentStoreException.convert(e.getCause(),
"Error occurred while fetching children for path "
+ path);
diff --git
a/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreService.java
b/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreService.java
index 0426d7b2ae..a651a53a7f 100644
---
a/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreService.java
+++
b/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreService.java
@@ -51,7 +51,6 @@ import java.util.function.Supplier;
import javax.sql.DataSource;
import org.apache.commons.lang3.StringUtils;
-import
org.apache.jackrabbit.guava.common.util.concurrent.UncheckedExecutionException;
import com.mongodb.ConnectionString;
import org.apache.commons.io.FilenameUtils;
@@ -1120,15 +1119,15 @@ public class DocumentNodeStoreService {
/**
* Returns the result of the last revision GC run. This method throws
- * an {@link UncheckedExecutionException} if the last run failed with
an
+ * an {@link RuntimeException} if the last run failed with an
* exception.
*
* @return result of the last revision GC run.
*/
@Override
- public String get() throws UncheckedExecutionException {
+ public String get() throws RuntimeException {
if (lastResult instanceof Exception) {
- throw new UncheckedExecutionException((Exception) lastResult);
+ throw new RuntimeException((Exception) lastResult);
}
return String.valueOf(lastResult);
}
diff --git
a/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/mongo/MongoDocumentStore.java
b/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/mongo/MongoDocumentStore.java
index 51199f00e7..fc6c0a8341 100644
---
a/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/mongo/MongoDocumentStore.java
+++
b/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/mongo/MongoDocumentStore.java
@@ -44,7 +44,6 @@ import java.util.stream.Collectors;
import java.util.stream.StreamSupport;
import org.apache.commons.io.IOUtils;
-import
org.apache.jackrabbit.guava.common.util.concurrent.UncheckedExecutionException;
import org.apache.jackrabbit.oak.cache.CacheStats;
import org.apache.jackrabbit.oak.cache.CacheValue;
import org.apache.jackrabbit.oak.commons.collections.IterableUtils;
@@ -643,8 +642,6 @@ public class MongoDocumentStore implements DocumentStore {
} else {
return (T) doc;
}
- } catch (UncheckedExecutionException e) {
- t = e.getCause();
} catch (ExecutionException e) {
t = e.getCause();
} catch (RuntimeException e) {
@@ -1834,7 +1831,7 @@ public class MongoDocumentStore implements DocumentStore {
}
}
return;
- } catch (UncheckedExecutionException | ExecutionException e) {
+ } catch (ExecutionException e) {
t = e.getCause();
} catch (RuntimeException e) {
t = e;