Bill commented on a change in pull request #6697:
URL: https://github.com/apache/geode/pull/6697#discussion_r678523007



##########
File path: 
geode-membership/src/main/java/org/apache/geode/distributed/internal/membership/gms/MemberIdentifierImpl.java
##########
@@ -282,49 +275,36 @@ public int compareTo(MemberIdentifier other, boolean 
compareMemberData,
       }
     }
 
-    String myName = getName();
-    String otherName = other.getName();
-    if (!(other.isPartial() || this.isPartial())) {
-      if (myName == null && otherName == null) {
-        // do nothing
-      } else if (myName == null) {
-        return -1;
-      } else if (otherName == null) {
-        return 1;
-      } else {
-        int i = myName.compareTo(otherName);
-        if (i != 0) {
-          return i;
-        }
+    if (!(other.isPartial() || isPartial())) {
+      c = StringUtils.compare(getName(), other.getName());

Review comment:
       bravissimo!

##########
File path: 
geode-membership/src/main/java/org/apache/geode/distributed/internal/membership/gms/MemberIdentifierImpl.java
##########
@@ -235,23 +232,19 @@ public boolean hasUUID() {
   }
 
   public int compare(MemberIdentifier other) {
-    return this.compareTo(other, false, true);
+    return compareTo(other, false, true);
   }
 
   @Override
-  public int compareTo(MemberIdentifier other, boolean compareMemberData,
-      boolean compareViewIds) {
-    int myPort = getMembershipPort();
-    int otherPort = other.getMembershipPort();
-    if (myPort < otherPort) {
-      return -1;
-    }
-    if (myPort > otherPort) {
-      return 1;
+  public int compareTo(final @NotNull MemberIdentifier other, final boolean 
compareMemberData,
+      final boolean compareViewIds) {
+    int c = Integer.compare(getMembershipPort(), other.getMembershipPort());

Review comment:
       I see why you made `c` mutable—so that you could use it to capture the 
result of subsequent comparisons below.
   
   If you wanted to make it `final` and make new `final` variables that would 
be ok too.




-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to