Skip to content

Commit 1ae9e57

Browse files
committed
Merge branch 'master' of github.com:FasterXML/jackson-databind
2 parents c3fdb53 + 6f65b00 commit 1ae9e57

File tree

1 file changed

+30
-33
lines changed

1 file changed

+30
-33
lines changed

src/main/java/com/fasterxml/jackson/databind/jsontype/impl/TypeDeserializerBase.java

Lines changed: 30 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
package com.fasterxml.jackson.databind.jsontype.impl;
22

33
import java.io.IOException;
4-
import java.util.HashMap;
4+
import java.util.Map;
5+
import java.util.concurrent.ConcurrentHashMap;
56

67
import com.fasterxml.jackson.annotation.JsonTypeInfo;
78
import com.fasterxml.jackson.core.*;
@@ -55,7 +56,7 @@ public abstract class TypeDeserializerBase
5556
* For efficient operation we will lazily build mappings from type ids
5657
* to actual deserializers, once needed.
5758
*/
58-
protected final HashMap<String,JsonDeserializer<Object>> _deserializers;
59+
protected final Map<String,JsonDeserializer<Object>> _deserializers;
5960

6061
protected JsonDeserializer<Object> _defaultImplDeserializer;
6162

@@ -72,7 +73,7 @@ protected TypeDeserializerBase(JavaType baseType, TypeIdResolver idRes,
7273
_idResolver = idRes;
7374
_typePropertyName = typePropertyName;
7475
_typeIdVisible = typeIdVisible;
75-
_deserializers = new HashMap<String,JsonDeserializer<Object>>();
76+
_deserializers = new ConcurrentHashMap<String, JsonDeserializer<Object>>();
7677
if (defaultImpl == null) {
7778
_defaultImpl = null;
7879
} else {
@@ -144,39 +145,35 @@ public String toString()
144145
protected final JsonDeserializer<Object> _findDeserializer(DeserializationContext ctxt, String typeId)
145146
throws IOException
146147
{
147-
JsonDeserializer<Object> deser;
148-
149-
synchronized (_deserializers) {
150-
deser = _deserializers.get(typeId);
151-
if (deser == null) {
152-
/* As per [Databind#305], need to provide contextual info. But for
153-
* backwards compatibility, let's start by only supporting this
154-
* for base class, not via interface. Later on we can add this
155-
* to the interface, assuming deprecation at base class helps.
148+
JsonDeserializer<Object> deser = _deserializers.get(typeId);
149+
if (deser == null) {
150+
/* As per [Databind#305], need to provide contextual info. But for
151+
* backwards compatibility, let's start by only supporting this
152+
* for base class, not via interface. Later on we can add this
153+
* to the interface, assuming deprecation at base class helps.
154+
*/
155+
JavaType type = _idResolver.typeFromId(ctxt, typeId);
156+
if (type == null) {
157+
// As per [JACKSON-614], use the default impl if no type id available:
158+
deser = _findDefaultImplDeserializer(ctxt);
159+
if (deser == null) {
160+
deser = _handleUnknownTypeId(ctxt, typeId, _idResolver, _baseType);
161+
}
162+
} else {
163+
/* 16-Dec-2010, tatu: Since nominal type we get here has no (generic) type parameters,
164+
* we actually now need to explicitly narrow from base type (which may have parameterization)
165+
* using raw type.
166+
*
167+
* One complication, though; can not change 'type class' (simple type to container); otherwise
168+
* we may try to narrow a SimpleType (Object.class) into MapType (Map.class), losing actual
169+
* type in process (getting SimpleType of Map.class which will not work as expected)
156170
*/
157-
JavaType type = _idResolver.typeFromId(ctxt, typeId);
158-
if (type == null) {
159-
// As per [JACKSON-614], use the default impl if no type id available:
160-
deser = _findDefaultImplDeserializer(ctxt);
161-
if (deser == null) {
162-
deser = _handleUnknownTypeId(ctxt, typeId, _idResolver, _baseType);
163-
}
164-
} else {
165-
/* 16-Dec-2010, tatu: Since nominal type we get here has no (generic) type parameters,
166-
* we actually now need to explicitly narrow from base type (which may have parameterization)
167-
* using raw type.
168-
*
169-
* One complication, though; can not change 'type class' (simple type to container); otherwise
170-
* we may try to narrow a SimpleType (Object.class) into MapType (Map.class), losing actual
171-
* type in process (getting SimpleType of Map.class which will not work as expected)
172-
*/
173-
if (_baseType != null && _baseType.getClass() == type.getClass()) {
174-
type = _baseType.narrowBy(type.getRawClass());
175-
}
176-
deser = ctxt.findContextualValueDeserializer(type, _property);
171+
if (_baseType != null && _baseType.getClass() == type.getClass()) {
172+
type = _baseType.narrowBy(type.getRawClass());
177173
}
178-
_deserializers.put(typeId, deser);
174+
deser = ctxt.findContextualValueDeserializer(type, _property);
179175
}
176+
_deserializers.put(typeId, deser);
180177
}
181178
return deser;
182179
}

0 commit comments

Comments
 (0)