You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ozone.apache.org by GitBox <gi...@apache.org> on 2019/11/17 13:57:19 UTC

[GitHub] [hadoop-ozone] adoroszlai commented on a change in pull request #198: HDDS-2501. Sonar: Fix issues found in the ObjectEndpoint class.

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:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: ozone-issues-unsubscribe@hadoop.apache.org
For additional commands, e-mail: ozone-issues-help@hadoop.apache.org