Skip to content

Commit c0f01a5

Browse files
committed
Pre-merge piece of #4101
1 parent e4d183f commit c0f01a5

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

src/main/java/com/fasterxml/jackson/databind/util/LRUMap.java

+7-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* Since Jackson 2.12, there has been pluggable {@link LookupCache} interface which
1616
* allows users, frameworks, provide their own cache implementations.
1717
*<p>
18-
* Snce Jackson 2.14, the implementation
18+
* Since Jackson 2.14, the implementation
1919
*<ul>
2020
*<li>Evicts the least recently used entry when max size is reached
2121
* </li>
@@ -45,6 +45,12 @@ public LRUMap(int initialEntries, int maxEntries)
4545
.build();
4646
}
4747

48+
// @since 2.16
49+
@Override
50+
public LookupCache<K,V> emptyCopy() {
51+
return new LRUMap<K,V>(_initialEntries, _maxEntries);
52+
}
53+
4854
@Override
4955
public V put(K key, V value) {
5056
return _map.put(key, value);

src/main/java/com/fasterxml/jackson/databind/util/LookupCache.java

+13-1
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,20 @@
99
*
1010
* @since 2.12 (for forwards-compatiblity with 3.0)
1111
*/
12-
public interface LookupCache <K,V>
12+
public interface LookupCache<K,V>
1313
{
14+
/**
15+
* Method needed for creating clones but without contents.
16+
*<p>
17+
* Default implementation th
18+
*
19+
* @since 2.16
20+
*/
21+
default LookupCache<K,V> emptyCopy() {
22+
throw new UnsupportedOperationException("LookupCache implementation "
23+
+getClass().getName()+" does not implement `emptyCopy()`");
24+
}
25+
1426
/**
1527
* @return Number of entries currently in cache: may be approximate, only
1628
* to be used for diagnostics, metrics reporting

0 commit comments

Comments
 (0)