File tree Expand file tree Collapse file tree 2 files changed +15
-2
lines changed
main/java/io/sentry/spring7/cache
test/kotlin/io/sentry/spring7/cache Expand file tree Collapse file tree 2 files changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -24,8 +24,8 @@ public SentryCacheManagerWrapper(
2424 @ Override
2525 public @ Nullable Cache getCache (final @ NotNull String name ) {
2626 final Cache cache = delegate .getCache (name );
27- if (cache == null ) {
28- return null ;
27+ if (cache == null || cache instanceof SentryCacheWrapper ) {
28+ return cache ;
2929 }
3030 return new SentryCacheWrapper (cache , scopes );
3131 }
Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ import io.sentry.IScopes
44import kotlin.test.Test
55import kotlin.test.assertEquals
66import kotlin.test.assertNull
7+ import kotlin.test.assertSame
78import kotlin.test.assertTrue
89import org.mockito.kotlin.mock
910import org.mockito.kotlin.whenever
@@ -36,6 +37,18 @@ class SentryCacheManagerWrapperTest {
3637 assertNull(result)
3738 }
3839
40+ @Test
41+ fun `getCache does not double-wrap SentryCacheWrapper` () {
42+ val innerCache = mock<Cache >()
43+ val alreadyWrapped = SentryCacheWrapper (innerCache, scopes)
44+ whenever(delegate.getCache(" test" )).thenReturn(alreadyWrapped)
45+
46+ val wrapper = SentryCacheManagerWrapper (delegate, scopes)
47+ val result = wrapper.getCache(" test" )
48+
49+ assertSame(alreadyWrapped, result)
50+ }
51+
3952 @Test
4053 fun `getCacheNames delegates to underlying cache manager` () {
4154 whenever(delegate.cacheNames).thenReturn(listOf (" cache1" , " cache2" ))
You can’t perform that action at this time.
0 commit comments