Skip to content

Comments

[SPARK-44337][PROTOBUF] Any fields set to 'Any.getDefaultInstance' cause parse errors#41897

Closed
rangadi wants to merge 2 commits intoapache:masterfrom
rangadi:any-default
Closed

[SPARK-44337][PROTOBUF] Any fields set to 'Any.getDefaultInstance' cause parse errors#41897
rangadi wants to merge 2 commits intoapache:masterfrom
rangadi:any-default

Conversation

@rangadi
Copy link

@rangadi rangadi commented Jul 8, 2023

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.getDefaultInstance can 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.

@rangadi
Copy link
Author

rangadi commented Jul 8, 2023

cc: @gengliangwang, @HeartSaVioR, @SandishKumarHN for review.

@HyukjinKwon HyukjinKwon changed the title [SPARK-44337] Any fields set to 'Any.getDefaultInstance' cause parse errors [SPARK-44337][PROTOBUF] Any fields set to 'Any.getDefaultInstance' cause parse errors Jul 10, 2023
@HyukjinKwon
Copy link
Member

Merged to master.

@rangadi
Copy link
Author

rangadi commented Jul 10, 2023

Thank you @HyukjinKwon (as usual :)).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants