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


##########
hadoop-ozone/s3gateway/src/main/java/org/apache/hadoop/ozone/s3/endpoint/ObjectEndpoint.java:
##########
@@ -198,12 +199,18 @@ Response handlePutRequest(ObjectRequestContext context, 
String keyPath, InputStr
     final long startNanos = context.getStartNanos();
 
     String copyHeader = null;
+    FileBackedOutputStream spooledBody = null;
     MultiDigestInputStream multiDigestInputStream = null;
     try {
       OzoneVolume volume = context.getVolume();
       OzoneBucket bucket = context.getBucket();
       final String lengthHeader = 
getHeaders().getHeaderString(HttpHeaders.CONTENT_LENGTH);
       long length = lengthHeader != null ? Long.parseLong(lengthHeader) : 0;
+      if (lengthHeader == null && body != null) {
+        spooledBody = new FileBackedOutputStream(getIOBufferSize(1));
+        length = IOUtils.copyLarge(body, spooledBody);

Review Comment:
   But we should use the configurable buffer here, instead of `IOUtils` default 
8KB:
   
   ```suggestion
           length = IOUtils.copyLarge(body, spooledBody, new 
byte[getIOBufferSize(0)]);
   ```



##########
hadoop-ozone/s3gateway/src/main/java/org/apache/hadoop/ozone/s3/endpoint/ObjectEndpoint.java:
##########
@@ -198,12 +199,18 @@ Response handlePutRequest(ObjectRequestContext context, 
String keyPath, InputStr
     final long startNanos = context.getStartNanos();
 
     String copyHeader = null;
+    FileBackedOutputStream spooledBody = null;
     MultiDigestInputStream multiDigestInputStream = null;
     try {
       OzoneVolume volume = context.getVolume();
       OzoneBucket bucket = context.getBucket();
       final String lengthHeader = 
getHeaders().getHeaderString(HttpHeaders.CONTENT_LENGTH);
       long length = lengthHeader != null ? Long.parseLong(lengthHeader) : 0;
+      if (lengthHeader == null && body != null) {
+        spooledBody = new FileBackedOutputStream(getIOBufferSize(1));

Review Comment:
   `getIOBufferSize(1)` can be simplified to `1`.
   
   Also, `FileBackedOutputStream.MemoryOutput extends ByteArrayOutputStream` 
creates a 32-byte internal buffer anyway, so we can set `fileThreshold = 32` 
without increasing memory requirement.
   
   ```suggestion
           spooledBody = new FileBackedOutputStream(32);
   ```



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