Skip to content

Commit fdb31cd

Browse files
committed
Check actual cache value for unwrapped Optional
Issue: SPR-14230
1 parent bd40a93 commit fdb31cd

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

spring-context/src/test/java/org/springframework/cache/CacheReproTests.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,10 +137,17 @@ public void spr13081ConfigFailIfCacheResolverReturnsNullCacheName() {
137137
public void spr14230AdaptsToOptional() {
138138
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(Spr14230Config.class);
139139
Spr14230Service bean = context.getBean(Spr14230Service.class);
140+
Cache cache = context.getBean(CacheManager.class).getCache("itemCache");
140141

141142
TestBean tb = new TestBean("tb1");
142143
bean.insertItem(tb);
143144
assertSame(tb, bean.findById("tb1").get());
145+
assertSame(tb, cache.get("tb1").get());
146+
147+
cache.clear();
148+
TestBean tb2 = bean.findById("tb1").get();
149+
assertNotSame(tb, tb2);
150+
assertSame(tb2, cache.get("tb1").get());
144151
}
145152

146153

0 commit comments

Comments
 (0)