You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-commits@jackrabbit.apache.org by re...@apache.org on 2026/04/29 10:34:01 UTC
(jackrabbit-oak) branch trunk updated: Revert "OAK-12200 : restored the exception handling logic to guava cache style (#2878)"
This is an automated email from the ASF dual-hosted git repository.
reschke 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 1b766a35cb Revert "OAK-12200 : restored the exception handling logic to guava cache style (#2878)"
1b766a35cb is described below
commit 1b766a35cb21b1acc6f6f56e7bf36d50b0e429df
Author: Julian Reschke <ju...@gmx.de>
AuthorDate: Wed Apr 29 11:33:40 2026 +0100
Revert "OAK-12200 : restored the exception handling logic to guava cache style (#2878)"
This reverts commit e38b98ff712ae79e749d3f24f5c64ed534f09dfe.
---
.../apache/jackrabbit/oak/segment/SegmentCache.java | 16 ++++------------
.../jackrabbit/oak/segment/file/FileStore.java | 16 ++--------------
.../jackrabbit/oak/segment/SegmentCacheTest.java | 16 ----------------
.../persistentcache/CachingPersistenceTest.java | 21 ---------------------
4 files changed, 6 insertions(+), 63 deletions(-)
diff --git a/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/SegmentCache.java b/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/SegmentCache.java
index 0f49eb119a..daf04a6bc2 100644
--- a/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/SegmentCache.java
+++ b/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/SegmentCache.java
@@ -167,9 +167,10 @@ public abstract class SegmentCache {
return segment;
} catch (Exception e) {
stats.loadExceptionCount.incrementAndGet();
- // Preserve the former Guava cache exception shape. Letting Caffeine
- // expose runtime loader failures directly broke FileStore RNE handling.
- throw new SegmentCacheLoaderException(e);
+ if (e instanceof RuntimeException) {
+ throw (RuntimeException) e;
+ }
+ throw new RuntimeException(e);
}
});
} catch (RuntimeException e) {
@@ -222,15 +223,6 @@ public abstract class SegmentCache {
}
}
- private static final class SegmentCacheLoaderException extends RuntimeException {
-
- private static final long serialVersionUID = 1L;
-
- private SegmentCacheLoaderException(@NotNull Exception cause) {
- super(cause);
- }
- }
-
/** An always empty cache */
private static class EmptyCache extends SegmentCache {
private final Stats stats = new Stats(NAME, 0, () -> 0L);
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 0ed54e314c..68a2c3a6cb 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
@@ -517,8 +517,8 @@ public class FileStore extends AbstractFileStore {
try (ShutDownCloser ignored = shutDown.keepAlive()) {
return segmentCache.getSegment(id, () -> readSegmentUncached(id));
} catch (ExecutionException | RuntimeException e) {
- RepositoryNotReachableException re = asRepositoryNotReachableException(e);
- if (re != null) {
+ if (e.getCause() instanceof RepositoryNotReachableException) {
+ RepositoryNotReachableException re = (RepositoryNotReachableException) e.getCause();
log.warn("Unable to access repository", re);
throw re;
}
@@ -530,18 +530,6 @@ public class FileStore extends AbstractFileStore {
}
}
- private static RepositoryNotReachableException asRepositoryNotReachableException(Exception e) {
- // Preserve the former Guava cache exception shape while also tolerating
- // Caffeine exposing runtime loader failures directly.
- if (e instanceof RepositoryNotReachableException) {
- return (RepositoryNotReachableException) e;
- }
- if (e.getCause() instanceof RepositoryNotReachableException) {
- return (RepositoryNotReachableException) e.getCause();
- }
- return null;
- }
-
@Override
public void writeSegment(SegmentId id, byte[] buffer, int offset, int length) throws IOException {
try (ShutDownCloser ignored = shutDown.keepAlive()) {
diff --git a/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/SegmentCacheTest.java b/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/SegmentCacheTest.java
index 038318b764..eb63dcd463 100644
--- a/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/SegmentCacheTest.java
+++ b/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/SegmentCacheTest.java
@@ -23,7 +23,6 @@ import static org.apache.jackrabbit.oak.segment.SegmentCache.newSegmentCache;
import static org.apache.jackrabbit.oak.segment.SegmentStore.EMPTY_STORE;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertSame;
import static org.junit.Assert.fail;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -33,7 +32,6 @@ import java.util.concurrent.ExecutionException;
import java.util.concurrent.atomic.AtomicBoolean;
import org.apache.jackrabbit.oak.cache.AbstractCacheStats;
-import org.apache.jackrabbit.oak.segment.spi.RepositoryNotReachableException;
import org.junit.Test;
public class SegmentCacheTest {
@@ -87,20 +85,6 @@ public class SegmentCacheTest {
}
}
- @Test
- public void getSegmentWrapsRuntimeLoaderFailureWithOriginalCause() throws ExecutionException {
- RepositoryNotReachableException failure = new RepositoryNotReachableException(null);
-
- try {
- cache.getSegment(id1, () -> {
- throw failure;
- });
- fail("expected RuntimeException");
- } catch (RuntimeException e) {
- assertSame(failure, e.getCause());
- }
- }
-
@Test
public void invalidateTests() throws ExecutionException {
cache.putSegment(segment1);
diff --git a/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/spi/persistence/persistentcache/CachingPersistenceTest.java b/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/spi/persistence/persistentcache/CachingPersistenceTest.java
index 0478d947b0..f096aa027c 100644
--- a/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/spi/persistence/persistentcache/CachingPersistenceTest.java
+++ b/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/spi/persistence/persistentcache/CachingPersistenceTest.java
@@ -90,27 +90,6 @@ public class CachingPersistenceTest {
}
}
- @Test(expected = RepositoryNotReachableException.class)
- public void fileStoreRethrowsRepositoryNotReachableForDataSegmentCacheMiss()
- throws IOException, InvalidFileStoreVersionException {
- FileStore fileStore = null;
- try {
- fileStore = getFileStoreBuilderWithCachingPersistence(false).build();
- SegmentId id = fileStore.getHead().getRecordId().getSegmentId();
- assertTrue(id.isDataSegmentId());
- fileStore.close();
-
- fileStore = getFileStoreBuilderWithCachingPersistence(true).build();
- id = new SegmentId(fileStore, id.getMostSignificantBits(), id.getLeastSignificantBits());
-
- fileStore.readSegment(id);
- } finally {
- if (fileStore != null) {
- fileStore.close();
- }
- }
- }
-
/**
* @param repoNotReachable - if set to true, {@code RepositoryNotReachableException} will be thrown when calling {@code SegmentArchiveReader}#readSegment
* @return