Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Dec 1, 2019
1 parent 9c646c8 commit c1250b7
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 13 deletions.
4 changes: 4 additions & 0 deletions release-notes/CREDITS-2.x
Original file line number Diff line number Diff line change
Expand Up @@ -1002,3 +1002,7 @@ Richard Wise (Woodz@github)
Mark Schäfer (mark--@github)
* Reported #2520: Sub-optimal exception message when failing to deserialize non-static inner classes
(2.10.1)
Fabian Lange (CodingFabian@github)
* Reported #2556: Contention in `TypeNameIdResolver.idFromClass()`
(2.10.2)
2 changes: 2 additions & 0 deletions release-notes/VERSION-2.x
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ Project: jackson-databind
(reported by Jon A)
#2553: JsonDeserialize(contentAs=...) broken with raw collections
(reported by cpopp@github)
#2556: Contention in `TypeNameIdResolver.idFromClass()`
(reported by Fabian L)

2.10.1 (09-Nov-2019)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,23 +88,29 @@ protected String idFromClass(Class<?> clazz)
if (clazz == null) {
return null;
}
Class<?> cls = _typeFactory.constructType(clazz).getRawClass();
final String key = cls.getName();
// NOTE: although we may need to let `TypeModifier` change actual type to use
// for id, we can use original type as key for more efficient lookup:
final String key = clazz.getName();
String name;

synchronized (_typeToId) {
name = _typeToId.get(key);
}

if (name == null) {
// 29-Nov-2019, tatu: As per test in `TestTypeModifierNameResolution` somehow
// we need to do this odd piece here which seems unnecessary but isn't.
Class<?> cls = _typeFactory.constructType(clazz).getRawClass();
// 24-Feb-2011, tatu: As per [JACKSON-498], may need to dynamically look up name
// can either throw an exception, or use default name...
if (_config.isAnnotationProcessingEnabled()) {
BeanDescription beanDesc = _config.introspectClassAnnotations(cls);
name = _config.getAnnotationIntrospector().findTypeName(beanDesc.getClassInfo());
}
if (name == null) {
// 24-Feb-2011, tatu: As per [JACKSON-498], may need to dynamically look up name
// can either throw an exception, or use default name...
if (_config.isAnnotationProcessingEnabled()) {
BeanDescription beanDesc = _config.introspectClassAnnotations(cls);
name = _config.getAnnotationIntrospector().findTypeName(beanDesc.getClassInfo());
}
if (name == null) {
// And if still not found, let's choose default?
name = _defaultTypeId(cls);
}
// And if still not found, let's choose default?
name = _defaultTypeId(cls);
}
synchronized (_typeToId) {
_typeToId.put(key, name);
}
}
Expand Down

0 comments on commit c1250b7

Please sign in to comment.