1
1
package com .fasterxml .jackson .databind .deser ;
2
2
3
3
import java .util .HashMap ;
4
- import java .util .concurrent .locks .ReentrantLock ;
5
4
6
5
import com .fasterxml .jackson .annotation .JsonFormat ;
7
6
import com .fasterxml .jackson .databind .*;
@@ -53,12 +52,6 @@ public final class DeserializerCache
53
52
protected final HashMap <JavaType , JsonDeserializer <Object >> _incompleteDeserializers
54
53
= new HashMap <JavaType , JsonDeserializer <Object >>(8 );
55
54
56
-
57
- /**
58
- * We hold an explicit lock while creating deserializers to avoid creating duplicates.
59
- */
60
- private final ReentrantLock _incompleteDeserializersLock = new ReentrantLock ();
61
-
62
55
/*
63
56
/**********************************************************
64
57
/* Life-cycle
@@ -249,12 +242,10 @@ protected JsonDeserializer<Object> _createAndCacheValueDeserializer(Deserializat
249
242
DeserializerFactory factory , JavaType type )
250
243
throws JsonMappingException
251
244
{
252
- /* Only one thread to construct deserializers at any given point in time;
253
- * limitations necessary to ensure that only completely initialized ones
254
- * are visible and used.
255
- */
256
- _incompleteDeserializersLock .lock ();
257
- try {
245
+ // Only one thread to construct deserializers at any given point in time;
246
+ // limitations necessary to ensure that only completely initialized ones
247
+ // are visible and used.
248
+ synchronized (_incompleteDeserializers ) {
258
249
// Ok, then: could it be that due to a race condition, deserializer can now be found?
259
250
JsonDeserializer <Object > deser = _findCachedDeserializer (type );
260
251
if (deser != null ) {
@@ -277,8 +268,6 @@ protected JsonDeserializer<Object> _createAndCacheValueDeserializer(Deserializat
277
268
_incompleteDeserializers .clear ();
278
269
}
279
270
}
280
- } finally {
281
- _incompleteDeserializersLock .unlock ();
282
271
}
283
272
}
284
273
0 commit comments