Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(166)

Issue 1852983002: Fix issues with protobuf equality comparisons (Closed)

Created:
4 years, 8 months ago by skybrian
Modified:
4 years, 8 months ago
Reviewers:
Søren Gjesse
CC:
reviews_dartlang.org
Base URL:
git@github.com:dart-lang/dart-protobuf.git@master
Target Ref:
refs/heads/master
Visibility:
Public.

Description

Fix issues with protobuf equality comparisons - Reading a repeated field could change equality comparisons, because repeated fields are initialized lazily. - If a GeneratedMessage implements Map, we would compare it as a map instead of as a GeneratedMessage. BUG=https://github.com/dart-lang/dart-protobuf/issues/48 R=sgjesse@google.com Committed: https://github.com/dart-lang/protobuf/commit/b301d29f82de0b69f293c83fba632bffb3d7d108

Patch Set 1 #

Total comments: 2

Patch Set 2 : tweak _deepEquals, improve tests #

Unified diffs Side-by-side diffs Delta from patch set Stats (+119 lines, -35 lines) Patch
M lib/src/protobuf/field_set.dart View 2 chunks +25 lines, -1 line 0 comments Download
M lib/src/protobuf/utils.dart View 1 1 chunk +3 lines, -0 lines 0 comments Download
M test/event_test.dart View 1 chunk +3 lines, -3 lines 0 comments Download
M test/json_test.dart View 1 chunk +3 lines, -3 lines 0 comments Download
M test/map_mixin_test.dart View 1 2 chunks +41 lines, -3 lines 0 comments Download
M test/message_test.dart View 1 2 chunks +31 lines, -9 lines 0 comments Download
M test/mock_util.dart View 2 chunks +13 lines, -16 lines 0 comments Download

Messages

Total messages: 7 (2 generated)
skybrian
4 years, 8 months ago (2016-04-02 02:53:23 UTC) #2
Søren Gjesse
lgtm, but shouldn't there be some new test? https://codereview.chromium.org/1852983002/diff/1/lib/src/protobuf/utils.dart File lib/src/protobuf/utils.dart (right): https://codereview.chromium.org/1852983002/diff/1/lib/src/protobuf/utils.dart#newcode10 lib/src/protobuf/utils.dart:10: if ...
4 years, 8 months ago (2016-04-04 16:06:27 UTC) #3
skybrian
Committed patchset #2 (id:20001) manually as b301d29f82de0b69f293c83fba632bffb3d7d108 (presubmit successful).
4 years, 8 months ago (2016-04-04 19:37:33 UTC) #5
skybrian
On 2016/04/04 16:06:27, Søren Gjesse wrote: > lgtm, but shouldn't there be some new test? ...
4 years, 8 months ago (2016-04-04 19:37:43 UTC) #6
skybrian
4 years, 8 months ago (2016-04-04 19:38:02 UTC) #7
Message was sent while issue was closed.
https://codereview.chromium.org/1852983002/diff/1/lib/src/protobuf/utils.dart
File lib/src/protobuf/utils.dart (right):

https://codereview.chromium.org/1852983002/diff/1/lib/src/protobuf/utils.dart...
lib/src/protobuf/utils.dart:10: if ((lhs is GeneratedMessage) && (rhs is
GeneratedMessage)) {
On 2016/04/04 16:06:27, Søren Gjesse wrote:
> Maybe negate this if to only have one lhs == rhs.
> 
> if (!(lhs is Gener... {
>   if ((lhs is List) ...
>   if ((lhs is List) ...
>   ...
> }
> return lhs == rhs

As a style thing, I'd rather repeat the == check than have nested if statements.

I changed this code slightly to ensure that if only one or the other is a
GeneratedMessage, it will return false. But I don't think this will come up in
practice except in contrived situations.

Powered by Google App Engine
This is Rietveld 408576698