shunping commented on code in PR #38531:
URL: https://github.com/apache/beam/pull/38531#discussion_r3262992338


##########
sdks/java/core/src/main/java/org/apache/beam/sdk/options/PipelineOptionsFactory.java:
##########
@@ -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());

Review Comment:
   Done



##########
sdks/java/core/src/main/java/org/apache/beam/sdk/options/PipelineOptionsFactory.java:
##########
@@ -1733,7 +1726,15 @@ 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 =
+          ((DefaultDeserializationContext) MAPPER.getDeserializationContext())
+              .createInstance(
+                  MAPPER.getDeserializationConfig(), dummyParser, new 
InjectableValues.Std());

Review Comment:
   Done



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to