File tree Expand file tree Collapse file tree 1 file changed +6
-2
lines changed
src/main/java/com/fasterxml/jackson/core/util Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change 1
1
package com .fasterxml .jackson .core .util ;
2
2
3
3
import java .util .concurrent .ConcurrentHashMap ;
4
+ import java .util .concurrent .locks .ReentrantLock ;
4
5
5
6
/**
6
7
* Singleton class that adds a simple first-level cache in front of
@@ -29,7 +30,7 @@ public final class InternCache
29
30
* cases where multiple threads might try to concurrently
30
31
* flush the map.
31
32
*/
32
- private final Object lock = new Object ();
33
+ private final ReentrantLock lock = new ReentrantLock ();
33
34
34
35
public InternCache () { this (MAX_ENTRIES , 0.8f , 4 ); }
35
36
@@ -51,10 +52,13 @@ public String intern(String input) {
51
52
* storage gives close enough answer to real one here; and we are
52
53
* more concerned with flooding than starvation.
53
54
*/
54
- synchronized (lock ) {
55
+ lock .lock ();
56
+ try {
55
57
if (size () >= MAX_ENTRIES ) {
56
58
clear ();
57
59
}
60
+ } finally {
61
+ lock .unlock ();
58
62
}
59
63
}
60
64
result = input .intern ();
You can’t perform that action at this time.
0 commit comments