Skip to content

Commit fdbd5e5

Browse files
authored
Merge pull request #2935 from cflxl/niyiming-dev
solve the unremoved result in keyList
2 parents 0fd8233 + 2cabe73 commit fdbd5e5

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2009-2022 the original author or authors.
2+
* Copyright 2009-2023 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.
@@ -64,6 +64,7 @@ public Object getObject(Object key) {
6464

6565
@Override
6666
public Object removeObject(Object key) {
67+
keyList.remove(key);
6768
return delegate.removeObject(key);
6869
}
6970

src/test/java/org/apache/ibatis/cache/FifoCacheTest.java

+12
Original file line numberDiff line numberDiff line change
@@ -60,4 +60,16 @@ void shouldFlushAllItemsOnDemand() {
6060
assertNull(cache.getObject(4));
6161
}
6262

63+
@Test
64+
void shouldRiseConflictInBeyondFiveEntries() {
65+
FifoCache cache = new FifoCache(new PerpetualCache("default"));
66+
cache.setSize(5);
67+
for (int i = 0; i < 5; i++) {
68+
cache.putObject(i, i);
69+
}
70+
cache.removeObject(1);
71+
cache.putObject(1, 1);
72+
assertNotNull(cache.getObject(0));
73+
}
74+
6375
}

0 commit comments

Comments
 (0)