Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix JRuby conformance issue by loosening Java's JSONFormatter implementation to be more accepting of DynamicMessage instances of well-known types that have a descriptor with a different object identity but the same full name. #19897

Merged
merged 1 commit into from
Jan 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion conformance/failure_list_jruby.txt
Original file line number Diff line number Diff line change
Expand Up @@ -144,4 +144,3 @@ Required.Editions_Proto2.ProtobufInput.UnknownOrdering.ProtobufOutput
Required.Editions_Proto3.ProtobufInput.UnknownOrdering.ProtobufOutput
Required.Proto2.ProtobufInput.UnknownOrdering.ProtobufOutput
Required.Proto3.ProtobufInput.UnknownOrdering.ProtobufOutput
Required.*.JsonInput.AnyWithNoType.JsonOutput # Failed to parse input or produce output.
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,17 @@ public int getSerializedSize() {
return memoizedSize;
}

/*
* This method will only ever return true if `this` and `other` have the same descriptor instance
* for their type (including a gencode message compared to a `DynamicMessage` constructed using
* the same descriptor instance).
*
* For reasons of backward compatibility, a comparison
* involving `DynamicMessage` that is constructed using semantically the same descriptor which
* was loaded separately (such that the reference identity of the descriptors does not match) will
* always return false even if there is otherwise no skew between the descriptors and the contents
* of the instances.
*/
@Override
public boolean equals(final Object other) {
if (other == this) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -862,7 +862,7 @@ public void print(PrinterImpl printer, MessageOrBuilder message) throws IOExcept

/** Prints google.protobuf.Any */
private void printAny(MessageOrBuilder message) throws IOException {
if (Any.getDefaultInstance().equals(message)) {
if (message.getDefaultInstanceForType().equals(message)) {
generator.print("{}");
return;
}
Expand Down
Loading