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 11package com .fasterxml .jackson .core .util ;
22
33import java .util .concurrent .ConcurrentHashMap ;
4+ import java .util .concurrent .locks .ReentrantLock ;
45
56/**
67 * Singleton class that adds a simple first-level cache in front of
@@ -29,7 +30,7 @@ public final class InternCache
2930 * cases where multiple threads might try to concurrently
3031 * flush the map.
3132 */
32- private final Object lock = new Object ();
33+ private final ReentrantLock lock = new ReentrantLock ();
3334
3435 public InternCache () { this (MAX_ENTRIES , 0.8f , 4 ); }
3536
@@ -51,10 +52,13 @@ public String intern(String input) {
5152 * storage gives close enough answer to real one here; and we are
5253 * more concerned with flooding than starvation.
5354 */
54- synchronized (lock ) {
55+ lock .lock ();
56+ try {
5557 if (size () >= MAX_ENTRIES ) {
5658 clear ();
5759 }
60+ } finally {
61+ lock .unlock ();
5862 }
5963 }
6064 result = input .intern ();
You can’t perform that action at this time.
0 commit comments