11package com .fasterxml .jackson .databind .deser ;
22
33import java .util .HashMap ;
4- import java .util .concurrent .locks .ReentrantLock ;
54
65import com .fasterxml .jackson .annotation .JsonFormat ;
76import com .fasterxml .jackson .databind .*;
@@ -53,12 +52,6 @@ public final class DeserializerCache
5352 protected final HashMap <JavaType , JsonDeserializer <Object >> _incompleteDeserializers
5453 = new HashMap <JavaType , JsonDeserializer <Object >>(8 );
5554
56-
57- /**
58- * We hold an explicit lock while creating deserializers to avoid creating duplicates.
59- */
60- private final ReentrantLock _incompleteDeserializersLock = new ReentrantLock ();
61-
6255 /*
6356 /**********************************************************
6457 /* Life-cycle
@@ -249,12 +242,10 @@ protected JsonDeserializer<Object> _createAndCacheValueDeserializer(Deserializat
249242 DeserializerFactory factory , JavaType type )
250243 throws JsonMappingException
251244 {
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 ) {
258249 // Ok, then: could it be that due to a race condition, deserializer can now be found?
259250 JsonDeserializer <Object > deser = _findCachedDeserializer (type );
260251 if (deser != null ) {
@@ -277,8 +268,6 @@ protected JsonDeserializer<Object> _createAndCacheValueDeserializer(Deserializat
277268 _incompleteDeserializers .clear ();
278269 }
279270 }
280- } finally {
281- _incompleteDeserializersLock .unlock ();
282271 }
283272 }
284273
0 commit comments