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


##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/bucket/OMBucketDeleteRequest.java:
##########
@@ -287,13 +288,17 @@ private boolean bucketContainsSnapshotInCache(
   )
   public static OMRequest blockBucketDeleteWithBucketLayoutFromOldClient(
       OMRequest req, ValidationContext ctx) throws IOException {
-    DeleteBucketRequest request = req.getDeleteBucketRequest();
-
-    if (request.hasBucketName() && request.hasVolumeName()) {
-      BucketLayout bucketLayout = ctx.getBucketLayout(
-          request.getVolumeName(), request.getBucketName());
-      bucketLayout.validateSupportedOperation();
+    if (ClientVersion.fromProtoValue(req.getVersion())
+        .compareTo(ClientVersion.BUCKET_LAYOUT_SUPPORT) < 0) {
+      DeleteBucketRequest request = req.getDeleteBucketRequest();
+
+      if (request.hasBucketName() && request.hasVolumeName()) {
+        BucketLayout bucketLayout = ctx.getBucketLayout(
+            request.getVolumeName(), request.getBucketName());
+        bucketLayout.validateSupportedOperation();
+      }
     }
     return req;

Review Comment:
   The same "return early if client is new enough" check can be added in all 
methods (changing only the enum value being compared to, and the return type 
(request/response)):
   
   ```java
       ClientVersion clientVersion = 
ClientVersion.fromProtoValue(req.getVersion());
       if (ClientVersion.BUCKET_LAYOUT_SUPPORT.compareTo(clientVersion) <= 0) {
         return req;
       }
   ```
   
   That would:
   - simplify this change,
   - help avoid checkstyle problems,
   - make the logic easier to understand for future readers of the code,
   - prepare for the future refactoring discussed in #6919.
   
   ```suggestion
       ClientVersion clientVersion = 
ClientVersion.fromProtoValue(req.getVersion());
       if (ClientVersion.BUCKET_LAYOUT_SUPPORT.compareTo(clientVersion) <= 0) {
         return req;
       }
   
       DeleteBucketRequest request = req.getDeleteBucketRequest();
   
       if (request.hasBucketName() && request.hasVolumeName()) {
         BucketLayout bucketLayout = ctx.getBucketLayout(
             request.getVolumeName(), request.getBucketName());
         bucketLayout.validateSupportedOperation();
       }
       return req;
   ```



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