Skip to content

Commit

Permalink
remove threadlocal for DESERIALIZATION_CONTEXT and use copy instead (#…
Browse files Browse the repository at this point in the history
…29952)

Co-authored-by: jierwang <[email protected]>
  • Loading branch information
jrthe42 and jierwang authored Jan 9, 2024
1 parent b666c64 commit 97ca443
Showing 1 changed file with 8 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -500,15 +500,12 @@ Class<T> getProxyClass() {
new ObjectMapper()
.registerModules(ObjectMapper.findModules(ReflectHelpers.findClassLoader()));

private static final ThreadLocal<DefaultDeserializationContext> DESERIALIZATION_CONTEXT =
ThreadLocal.withInitial(
() ->
new DefaultDeserializationContext.Impl(
MAPPER.getDeserializationContext().getFactory())
.createInstance(
MAPPER.getDeserializationConfig(),
new TokenBuffer(MAPPER, false).asParser(),
new InjectableValues.Std()));
private static final DefaultDeserializationContext DESERIALIZATION_CONTEXT =
new DefaultDeserializationContext.Impl(MAPPER.getDeserializationContext().getFactory())
.createInstance(
MAPPER.getDeserializationConfig(),
new TokenBuffer(MAPPER, false).asParser(),
new InjectableValues.Std());

static final DefaultSerializerProvider SERIALIZER_PROVIDER =
new DefaultSerializerProvider.Impl()
Expand Down Expand Up @@ -1731,7 +1728,7 @@ private static JsonDeserializer<Object> computeDeserializerForMethod(Method meth
BeanProperty prop = createBeanProperty(method);
AnnotatedMember annotatedMethod = prop.getMember();

DefaultDeserializationContext context = DESERIALIZATION_CONTEXT.get();
DefaultDeserializationContext context = DESERIALIZATION_CONTEXT.copy();
Object maybeDeserializerClass =
context.getAnnotationIntrospector().findDeserializer(annotatedMethod);

Expand Down Expand Up @@ -1803,7 +1800,7 @@ static Object deserializeNode(JsonNode node, Method method) throws IOException {
parser.nextToken();

JsonDeserializer<Object> jsonDeserializer = getDeserializerForMethod(method);
return jsonDeserializer.deserialize(parser, DESERIALIZATION_CONTEXT.get());
return jsonDeserializer.deserialize(parser, DESERIALIZATION_CONTEXT.copy());
}

/**
Expand Down

0 comments on commit 97ca443

Please sign in to comment.