1
1
package com .fasterxml .jackson .databind .jsontype .impl ;
2
2
3
3
import java .util .*;
4
+ import java .util .concurrent .ConcurrentHashMap ;
4
5
5
6
import com .fasterxml .jackson .annotation .JsonTypeInfo ;
6
7
import com .fasterxml .jackson .databind .BeanDescription ;
@@ -28,8 +29,8 @@ protected TypeNameIdResolver(MapperConfig<?> config, JavaType baseType,
28
29
{
29
30
super (baseType , config .getTypeFactory ());
30
31
_config = config ;
31
- _typeToId = typeToId ;
32
- _idToType = idToType ;
32
+ _typeToId = new ConcurrentHashMap < String , String >( typeToId ) ;
33
+ _idToType = new ConcurrentHashMap < String , JavaType >( idToType ) ;
33
34
}
34
35
35
36
public static TypeNameIdResolver construct (MapperConfig <?> config , JavaType baseType ,
@@ -91,10 +92,7 @@ protected String idFromClass(Class<?> clazz)
91
92
// NOTE: although we may need to let `TypeModifier` change actual type to use
92
93
// for id, we can use original type as key for more efficient lookup:
93
94
final String key = clazz .getName ();
94
- String name ;
95
- synchronized (_typeToId ) {
96
- name = _typeToId .get (key );
97
- }
95
+ String name = _typeToId .get (key );
98
96
99
97
if (name == null ) {
100
98
// 29-Nov-2019, tatu: As per test in `TestTypeModifierNameResolution` somehow
@@ -110,9 +108,7 @@ protected String idFromClass(Class<?> clazz)
110
108
// And if still not found, let's choose default?
111
109
name = _defaultTypeId (cls );
112
110
}
113
- synchronized (_typeToId ) {
114
- _typeToId .put (key , name );
115
- }
111
+ _typeToId .put (key , name );
116
112
}
117
113
return name ;
118
114
}
0 commit comments