[SPARK-44337][PROTOBUF] Any fields set to 'Any.getDefaultInstance' cause parse errors#41897
Closed
rangadi wants to merge 2 commits intoapache:masterfrom
Closed
[SPARK-44337][PROTOBUF] Any fields set to 'Any.getDefaultInstance' cause parse errors#41897rangadi wants to merge 2 commits intoapache:masterfrom
rangadi wants to merge 2 commits intoapache:masterfrom
Conversation
Author
|
cc: @gengliangwang, @HeartSaVioR, @SandishKumarHN for review. |
SandishKumarHN
approved these changes
Jul 10, 2023
HyukjinKwon
approved these changes
Jul 10, 2023
Member
|
Merged to master. |
Author
|
Thank you @HyukjinKwon (as usual :)). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changes were proposed in this pull request?
While building the Protobuf descriptor from FileDescriptorSet, this PR uses bundled Java descriptor for 'google/protobuf/any.proto'. This works around a bug in Protobuf's JsonFormat while parsing Any fields initialized with
Any.getDefaultInstance().An existing test for Any fields is updated to test this case. Without the fix, the test passes with Java classes, but fails with FileDescriptorSet bytes. The latter is the common use case.
The bug in JsonFormat is related to how it checks for Any values at runtime that were originally initialized with
Any.getDefaultInstance(). Specifically the conditional here in JsonFormat.java fails since it tries to compare with actual default instance in Java from Java descriptor. If we build the same descriptor separately, JsonFormat does not recognize it.Why are the changes needed?
Without this fix, input that includes fields initialized to
Any.getDefaultInstancecan not be parsed.Does this PR introduce any user-facing change?
No.
How was this patch tested?
An existing unit test is updated to test this case.