Chung-En Lee created HDDS-17755:
-----------------------------------

             Summary: Use ComponentVersion#isSupportedBy instead of compareTo 
for OM version checks
                 Key: HDDS-17755
                 URL: https://issues.apache.org/jira/browse/HDDS-17755
             Project: Apache Ozone
          Issue Type: Task
            Reporter: Chung-En Lee


The javadoc of {{ComponentVersion#serialize}} says version checks should use 
{{isSupportedBy}}. Some OM version checks still use {{compareTo}} (line numbers 
from master {{fe23fc9985}}):
* {{RpcClient.java:1581}} {{checkIfNoneMatchETagSupport}}: 
{{getOmVersion().compareTo(OzoneManagerVersion.S3_IF_NONE_MATCH_ETAG) < 0}}
* {{BasicRootedOzoneClientAdapterImpl.java}}, all 
{{proxy.getOmVersion().compareTo(...) >= 0}}:
** {{:395}} {{GET_KEY_INFO_REJECTS_OBS}}
** {{:744}} {{GET_FILE_STATUS_REJECTS_OBS}}
** {{:1014}} {{LIST_STATUS_REJECTS_OBS}}
** {{:1472}} {{LOOKUP_FILE_REJECTS_OBS}}

{{compareTo}} follows the enum declaration order. It gives the right answer 
today only because {{UNKNOWN_VERSION}} is declared last, while 
{{isSupportedBy}} handles unknown future versions explicitly.

Proposal: replace {{v.compareTo(X) >= 0}} with {{X.isSupportedBy(v)}}, and 
{{v.compareTo(X) < 0}} with {{!X.isSupportedBy(v)}}.



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

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

Reply via email to