You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pulsar.apache.org by GitBox <gi...@apache.org> on 2020/09/01 07:28:53 UTC

[GitHub] [pulsar-dotpulsar] blankensteiner commented on a change in pull request #50: Fix checking MessageId against null throwing NRE

blankensteiner commented on a change in pull request #50:
URL: https://github.com/apache/pulsar-dotpulsar/pull/50#discussion_r480917670



##########
File path: src/DotPulsar/MessageId.cs
##########
@@ -76,13 +76,13 @@ public override bool Equals(object o)
             => o is MessageId id && Equals(id);
 
         public bool Equals(MessageId other)
-            => LedgerId == other.LedgerId && EntryId == other.EntryId && Partition == other.Partition && BatchIndex == other.BatchIndex;
+            => !(other is null) && LedgerId == other.LedgerId && EntryId == other.EntryId && Partition == other.Partition && BatchIndex == other.BatchIndex;
 
         public static bool operator ==(MessageId x, MessageId y)
-            => x.Equals(y);
+            => object.ReferenceEquals(x, y) || (!object.ReferenceEquals(x, null) && x.Equals(y));

Review comment:
       Just curious but why "!object.ReferenceEquals(x, null)" instead of "!(x is null)" or "x != null"?




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org