You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[SPARK-44337][PROTOBUF] Any fields set to 'Any.getDefaultInstance' cause parse errors
### 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](https://github.com/protocolbuffers/protobuf/blob/51f79d4415338cfe068a39d7ce466870df223245/java/util/src/main/java/com/google/protobuf/util/JsonFormat.java#L860) 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.
Closes#41897 from rangadi/any-default.
Authored-by: Raghu Angadi <[email protected]>
Signed-off-by: Hyukjin Kwon <[email protected]>
0 commit comments