Fix PipelineOptions display-data NPE#38525
Conversation
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request addresses a NullPointerException occurring during PipelineOptions display-data serialization, specifically observed with newer Jackson versions. It introduces a defensive fallback mechanism in the deserialization logic to ensure stability when contextual deserializers fail, and includes a regression test to prevent future occurrences. Highlights
New Features🧠 You can now enable Memory (public preview) to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize the Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counterproductive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request addresses a NullPointerException in PipelineOptionsFactory.deserializeNode that occurs with Jackson 2.18+ during display-data serialization. The changes introduce a null check for the deserializer and a try-catch block to fall back to standard Jackson deserialization if the custom deserializer fails. A regression test has been added to ensure stability. Review feedback suggests optimizing the deserializeNode method by moving the construction of JavaType into the specific fallback blocks where it is used, thereby avoiding unnecessary overhead in the common successful execution path.
|
Checks are failing. Will not request review until checks are succeeding. If you'd like to override that behavior, comment |
| JsonParser parser = new TreeTraversingParser(node, MAPPER); | ||
| parser.nextToken(); | ||
| return jsonDeserializer.deserialize(parser, DESERIALIZATION_CONTEXT.copy()); | ||
| } catch (NullPointerException e) { |
There was a problem hiding this comment.
catch an NPE is almost always an anti-pattern. Let me check what happens caused NPE here, and stack trace?
There was a problem hiding this comment.
ahh right it is not a long term fix, i refactored it and her'es the stack trace:
java.lang.IllegalArgumentException: Error while populating display data for component
'org.apache.beam.sdk.options.ProxyInvocationHandler$PipelineOptionsDisplayData': null
at PipelineOptionsTranslation.toProto(...)
at FlinkJobInvoker.createJobInvocation(...)
...
Caused by: java.lang.NullPointerException
at PipelineOptionsFactory.deserializeNode(PipelineOptionsFactory.java:1813)
at ProxyInvocationHandler.getValueFromJson(...)
at ProxyInvocationHandler$PipelineOptionsDisplayData.populateDisplayData(...:446)
at DisplayData.from(...)
at ProxyInvocationHandler$Serializer.serialize(...)
Caused by: java.lang.NullPointerException
at org.apache.beam.sdk.options.PipelineOptionsFactory.deserializeNode(...)
at org.apache.beam.sdk.options.ProxyInvocationHandler.getValueFromJson(...)
at org.apache.beam.sdk.options.ProxyInvocationHandler$PipelineOptionsDisplayData.populateDisplayData(...:446)
at org.apache.beam.sdk.transforms.display.DisplayData.from(...)
at org.apache.beam.sdk.options.ProxyInvocationHandler$Serializer.serialize(...)
at org.apache.beam.sdk.util.construction.PipelineOptionsTranslation.toProto(...)
at org.apache.beam.runners.flink.FlinkJobInvoker.createJobInvocation(...)
|
Stopping reviewer notifications for this pull request: review requested by someone other than the bot, ceding control. If you'd like to restart, comment |
Fixes: #37273
Successful run: https://github.com/apache/beam/actions/runs/26025239650
Thank you for your contribution! Follow this checklist to help us incorporate your contribution quickly and easily:
addresses #123), if applicable. This will automatically add a link to the pull request in the issue. If you would like the issue to automatically close on merging the pull request, commentfixes #<ISSUE NUMBER>instead.CHANGES.mdwith noteworthy changes.See the Contributor Guide for more tips on how to make review process smoother.
To check the build health, please visit https://github.com/apache/beam/blob/master/.test-infra/BUILD_STATUS.md
GitHub Actions Tests Status (on master branch)
See CI.md for more information about GitHub Actions CI or the workflows README to see a list of phrases to trigger workflows.