errose28 commented on code in PR #9841:
URL: https://github.com/apache/ozone/pull/9841#discussion_r2873454724


##########
hadoop-hdds/common/src/main/java/org/apache/hadoop/ozone/ClientVersion.java:
##########
@@ -70,18 +68,24 @@ public int serialize() {
     return version;
   }
 
+  public static ClientVersion deserialize(int value) {
+    return BY_VALUE.getOrDefault(value, FUTURE_VERSION);
+  }
+
   @Override
-  public String toString() {
-    return name() + " (" + serialize() + ")";
+  public boolean isSupportedBy(int serializedVersion) {
+    // In order for the other serialized version to support this version's 
features,
+    // the other version must be equal or larger to this version.
+    return deserialize(serializedVersion).compareTo(this) >= 0;
   }
 
-  public static ClientVersion fromProtoValue(int value) {
-    return BY_PROTO_VALUE.getOrDefault(value, FUTURE_VERSION);
+  @Override
+  public String toString() {
+    return name() + " (" + serialize() + ")";
   }
 
   private static ClientVersion latest() {
-    return Arrays.stream(ClientVersion.values())
-        
.max(Comparator.comparingInt(ComponentVersion::serialize)).orElse(null);
+    ClientVersion[] versions = ClientVersion.values();
+    return versions[versions.length - 2];

Review Comment:
   `values()` retrieves the versions in the order they occur in the enum. `-1` 
is the last value in the enum, which is `FUTURE_VERSION`. Here we actually want 
to latest version of the software, which is `-2`.
   
   This is a copy/paste from the existing `latest` implementations in 
`HDDSVersion` and `OzoneManagerVersion`, I just updated it here to have the 
same implementation to remove the stream without changing the functionality. I 
will add comments to all locations to explain this.



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to