Skip to content

Commit 43b13ca

Browse files
authored
Merge pull request #2438 from linmeitianqing/master
fix #2403
2 parents 64260ed + 0db20e2 commit 43b13ca

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

src/main/java/org/apache/ibatis/cache/decorators/SoftCache.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2009-2021 the original author or authors.
2+
* Copyright 2009-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -87,7 +87,9 @@ public Object getObject(Object key) {
8787
@Override
8888
public Object removeObject(Object key) {
8989
removeGarbageCollectedItems();
90-
return delegate.removeObject(key);
90+
@SuppressWarnings("unchecked")
91+
SoftReference<Object> softReference = (SoftReference<Object>) delegate.removeObject(key);
92+
return softReference == null ? null : softReference.get();
9193
}
9294

9395
@Override

src/main/java/org/apache/ibatis/cache/decorators/WeakCache.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2009-2021 the original author or authors.
2+
* Copyright 2009-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -86,7 +86,9 @@ public Object getObject(Object key) {
8686
@Override
8787
public Object removeObject(Object key) {
8888
removeGarbageCollectedItems();
89-
return delegate.removeObject(key);
89+
@SuppressWarnings("unchecked")
90+
WeakReference<Object> weakReference = (WeakReference<Object>) delegate.removeObject(key);
91+
return weakReference == null ? null : weakReference.get();
9092
}
9193

9294
@Override

0 commit comments

Comments
 (0)