adoroszlai commented on a change in pull request #198: HDDS-2501. Sonar: Fix 
issues found in the ObjectEndpoint class.
URL: https://github.com/apache/hadoop-ozone/pull/198#discussion_r347127562
 
 

 ##########
 File path: 
hadoop-ozone/s3gateway/src/main/java/org/apache/hadoop/ozone/s3/endpoint/ObjectEndpoint.java
 ##########
 @@ -546,39 +540,39 @@ private Response createMultipartKey(String bucket, 
String key, long length,
       throws IOException, OS3Exception {
     try {
       OzoneBucket ozoneBucket = getBucket(bucket);
-      OzoneOutputStream ozoneOutputStream = ozoneBucket.createMultipartKey(
-          key, length, partNumber, uploadID);
-
-      String copyHeader = headers.getHeaderString(COPY_SOURCE_HEADER);
-      if (copyHeader != null) {
-        Pair<String, String> result = parseSourceHeader(copyHeader);
-
-        String sourceBucket = result.getLeft();
-        String sourceKey = result.getRight();
-
-        try (OzoneInputStream sourceObject =
-            getBucket(sourceBucket).readKey(sourceKey)) {
-
-          String range =
-              headers.getHeaderString(COPY_SOURCE_HEADER_RANGE);
-          if (range != null) {
-            RangeHeader rangeHeader =
-                RangeHeaderParserUtil.parseRangeHeader(range, 0);
-            IOUtils.copyLarge(sourceObject, ozoneOutputStream,
-                rangeHeader.getStartOffset(),
-                rangeHeader.getEndOffset() - rangeHeader.getStartOffset());
-
-          } else {
-            IOUtils.copy(sourceObject, ozoneOutputStream);
+      String copyHeader;
+      OmMultipartCommitUploadPartInfo omMultipartCommitUploadPartInfo;
+      try (OzoneOutputStream ozoneOutputStream = 
ozoneBucket.createMultipartKey(
+          key, length, partNumber, uploadID)) {
+        copyHeader = headers.getHeaderString(COPY_SOURCE_HEADER);
+        if (copyHeader != null) {
+          Pair<String, String> result = parseSourceHeader(copyHeader);
+
+          String sourceBucket = result.getLeft();
+          String sourceKey = result.getRight();
+
+          try (OzoneInputStream sourceObject =
+                   getBucket(sourceBucket).readKey(sourceKey)) {
+
+            String range =
+                headers.getHeaderString(COPY_SOURCE_HEADER_RANGE);
+            if (range != null) {
+              RangeHeader rangeHeader =
+                  RangeHeaderParserUtil.parseRangeHeader(range, 0);
+              IOUtils.copyLarge(sourceObject, ozoneOutputStream,
+                  rangeHeader.getStartOffset(),
+                  rangeHeader.getEndOffset() - rangeHeader.getStartOffset());
+
+            } else {
+              IOUtils.copy(sourceObject, ozoneOutputStream);
+            }
           }
+        } else {
+          IOUtils.copy(body, ozoneOutputStream);
         }
-
-      } else {
-        IOUtils.copy(body, ozoneOutputStream);
+        omMultipartCommitUploadPartInfo = ozoneOutputStream
+            .getCommitUploadPartInfo();
 
 Review comment:
   It turns out this should be called only after `ozoneOutputStream` is closed 
(see #206).

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

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

Reply via email to