Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/trigger_files/beam_PreCommit_Python_PVR_Flink.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"comment": "Modify this file in a trivial way to cause this test suite to run",
"revision": 1
}
Original file line number Diff line number Diff line change
Expand Up @@ -502,13 +502,6 @@ Class<T> getProxyClass() {
new ObjectMapper()
.registerModules(ObjectMapper.findModules(ReflectHelpers.findClassLoader()));

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()
.createInstance(MAPPER.getSerializationConfig(), MAPPER.getSerializerFactory());
Comment thread
shunping marked this conversation as resolved.
Expand Down Expand Up @@ -1733,7 +1726,12 @@ private static JsonDeserializer<Object> computeDeserializerForMethod(Method meth
BeanProperty prop = createBeanProperty(method);
AnnotatedMember annotatedMethod = prop.getMember();

DefaultDeserializationContext context = DESERIALIZATION_CONTEXT.copy();
// Initialize a new context that is properly associated with a dummy parser.
// Using copy() here would leave the context's transient parser field as null,
// causing NullPointerExceptions in Jackson 2.14+ when deserializers try to
// query the parser for format constraints or coercion validations.
JsonParser dummyParser = new TokenBuffer(MAPPER, false).asParser();
DefaultDeserializationContext context = createDeserializationContext(dummyParser);
Object maybeDeserializerClass =
context.getAnnotationIntrospector().findDeserializer(annotatedMethod);

Expand All @@ -1756,6 +1754,11 @@ private static JsonDeserializer<Object> computeDeserializerForMethod(Method meth
}
}

private static DefaultDeserializationContext createDeserializationContext(JsonParser parser) {
return ((DefaultDeserializationContext) MAPPER.getDeserializationContext())
.createInstance(MAPPER.getDeserializationConfig(), parser, new InjectableValues.Std());
}

private static Optional<JsonSerializer<Object>> computeCustomSerializerForMethod(Method method) {
try {
BeanProperty prop = createBeanProperty(method);
Expand Down Expand Up @@ -1805,7 +1808,12 @@ static Object deserializeNode(JsonNode node, Method method) throws IOException {
parser.nextToken();

JsonDeserializer<Object> jsonDeserializer = getDeserializerForMethod(method);
return jsonDeserializer.deserialize(parser, DESERIALIZATION_CONTEXT.copy());
// Create a fresh context that is correctly associated with the active parser.
// Using copy() here would leave the context's transient parser field as null,
// causing NullPointerExceptions in Jackson 2.14+ deserializers during coercion
// validations and length checks.
DefaultDeserializationContext context = createDeserializationContext(parser);
return jsonDeserializer.deserialize(parser, context);
}

/**
Expand Down
Loading