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 generic comparisons on protobuf messages #241

Merged
merged 1 commit into from Nov 6, 2019

Conversation

@dsnet
Copy link
Contributor

dsnet commented Nov 6, 2019

Generated protobuf messages contain internal data structures
that general purpose comparison functions (e.g., reflect.DeepEqual,
pretty.Compare, etc) do not properly compare. It is already the case
today that these functions may report a difference when two messages
are actually semantically equivalent.

Fix all usages by either calling proto.Equal directly if
the top-level types are themselves proto.Message, or by calling
cmp.Equal with the cmp.Comparer(proto.Equal) option specified.
This option teaches cmp to use proto.Equal anytime it encounters
proto.Message types.

Generated protobuf messages contain internal data structures
that general purpose comparison functions (e.g., reflect.DeepEqual,
pretty.Compare, etc) do not properly compare. It is already the case
today that these functions may report a difference when two messages
are actually semantically equivalent.

Fix all usages by either calling proto.Equal directly if
the top-level types are themselves proto.Message, or by calling
cmp.Equal with the cmp.Comparer(proto.Equal) option specified.
This option teaches cmp to use proto.Equal anytime it encounters
proto.Message types.

Signed-off-by: Joe Tsai <joetsai@digital-static.net>
@dsnet dsnet force-pushed the dsnet:master branch from d2010d7 to a7a58be Nov 6, 2019
@dsnet

This comment has been minimized.

Copy link
Contributor Author

dsnet commented Nov 6, 2019

\cc @nareddyt

@kyessenov kyessenov self-requested a review Nov 6, 2019
Copy link
Contributor

kyessenov left a comment

Thanks, learning something new about protos.

@kyessenov kyessenov merged commit 2e02e0e into envoyproxy:master Nov 6, 2019
2 checks passed
2 checks passed
DCO DCO
Details
ci/circleci Your tests passed on CircleCI!
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.