adoroszlai commented on code in PR #11311:
URL: https://github.com/apache/ozone/pull/11311#discussion_r4090888449


##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/validation/VersionExtractor.java:
##########
@@ -30,36 +30,29 @@ public enum VersionExtractor {
   /**
    * Extracts current metadata layout version.
    */
-  LAYOUT_VERSION_EXTRACTOR {
-    @Override
-    public Versioned extractVersion(OMRequest req, ValidationContext ctx) {
-      LayoutVersionManager layoutVersionManager = ctx.versionManager();
-      return 
ctx.versionManager().getFeature(layoutVersionManager.getMetadataLayoutVersion());
-    }
-
-    @Override
-    public Class<? extends Annotation> getValidatorClass() {
-      return OMLayoutVersionValidator.class;
-    }
-  },
+  LAYOUT_VERSION_EXTRACTOR,
 
   /**
    * Extracts client version from the OMRequests.
    */
-  CLIENT_VERSION_EXTRACTOR {
-    @Override
-    public Versioned extractVersion(OMRequest req, ValidationContext ctx) {
-      return req.getVersion() > ClientVersion.CURRENT_VERSION ?
-          ClientVersion.FUTURE_VERSION : 
ClientVersion.fromProtoValue(req.getVersion());
-    }
+  CLIENT_VERSION_EXTRACTOR;
 
-    @Override
-    public Class<? extends Annotation> getValidatorClass() {
-      return OMClientVersionValidator.class;
+  public Versioned extractVersion(OMRequest req, ValidationContext ctx) {
+    return switch (this) {
+    case LAYOUT_VERSION_EXTRACTOR -> {
+      LayoutVersionManager layoutVersionManager = ctx.versionManager();
+      yield 
ctx.versionManager().getFeature(layoutVersionManager.getMetadataLayoutVersion());

Review Comment:
   Ah, I also noticed this existing code smell, but forgot to fix it.



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