frankgh commented on code in PR #291:
URL: https://github.com/apache/cassandra-sidecar/pull/291#discussion_r2578291099


##########
vertx-client/src/main/java/org/apache/cassandra/sidecar/client/VertxHttpClient.java:
##########
@@ -237,6 +234,30 @@ protected CompletableFuture<HttpResponse> 
executeUploadFileInternal(SidecarInsta
         return promise.future().toCompletionStage().toCompletableFuture();
     }
 
+    /**
+     * Sends the file stream via HTTP request.
+     *
+     * @param vertxRequest the HTTP request to send the file stream with
+     * @param pair a pair containing file size and the AsyncFile handle
+     * @return a Future that completes when the file has been sent
+     */
+    protected Future<io.vertx.ext.web.client.HttpResponse<Buffer>> 
sendFileStream(
+        HttpRequest<Buffer> vertxRequest,
+        AbstractMap.SimpleEntry<Long, AsyncFile> pair)
+    {
+        AsyncFile asyncFile = pair.getValue();
+        return vertxRequest.ssl(config.ssl())
+                           
.putHeader(HttpHeaderNames.CONTENT_LENGTH.toString(),
+                                      valueOf(pair.getKey()))
+                           .sendStream(pair.getValue()
+                                           
.setReadBufferSize(config.sendReadBufferSize()))
+                           .onComplete(ar -> {
+                               asyncFile.close().onFailure(err ->
+                                   LOGGER.warn("Failed to close file after 
upload", err)
+                               );
+                           });

Review Comment:
   Can we also log the filename here?
   ```suggestion
                              .onComplete(ar -> asyncFile.close().onFailure(err 
->
                                  LOGGER.warn("Failed to close file='{}' after 
upload", filename, err)
                              ));
   ```



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