@@ -232,10 +232,10 @@ private Future<Void> cloudRefresh() {
232232
233233 Promise <Void > refreshPromise = Promise .promise ();
234234 this .isRefreshing = true ;
235- vertx .< Void > executeBlocking (blockBromise -> {
235+ vertx .executeBlocking (() -> {
236236 this .cloudRefreshEnsureInSync (refreshPromise , 0 );
237- blockBromise . complete () ;
238- }, ar -> {} );
237+ return null ;
238+ });
239239
240240 return refreshPromise .future ()
241241 .onComplete (v -> {
@@ -320,12 +320,13 @@ private void handleUpload(Message<String> msg) {
320320 this .pendingUpload .add (fileToUpload );
321321 }
322322
323- this .uploadExecutor .<Void >executeBlocking (
324- promise -> this .cloudUploadBlocking (promise , msg .body ()),
325- ar -> {
326- this .pendingUpload .remove (fileToUpload );
327- this .handleAsyncResult (ar );
328- msg .reply (ar .succeeded ());
323+ this .uploadExecutor .executeBlocking (() -> {
324+ this .cloudUploadBlocking (msg .body ());
325+ return null ;
326+ }).onComplete (ar -> {
327+ this .pendingUpload .remove (fileToUpload );
328+ this .handleAsyncResult (ar );
329+ msg .reply (ar .succeeded ());
329330
330331 // increase counter
331332 if (ar .succeeded ()) {
@@ -338,16 +339,10 @@ private void handleUpload(Message<String> msg) {
338339 });
339340 }
340341
341- private void cloudUploadBlocking (Promise <Void > promise , String fileToUpload ) {
342- try {
343- String cloudPath = this .cloudSync .toCloudPath (fileToUpload );
344- try (InputStream localInput = this .localStorage .download (fileToUpload )) {
345- this .cloudStorage .upload (localInput , cloudPath );
346- }
347- promise .complete ();
348- } catch (Exception ex ) {
349- LOGGER .error (ex .getMessage (), ex );
350- promise .fail (new Throwable (ex ));
342+ private void cloudUploadBlocking (String fileToUpload ) throws Exception {
343+ String cloudPath = this .cloudSync .toCloudPath (fileToUpload );
344+ try (InputStream localInput = this .localStorage .download (fileToUpload )) {
345+ this .cloudStorage .upload (localInput , cloudPath );
351346 }
352347 }
353348
@@ -364,9 +359,10 @@ private Future<Void> cloudDownloadFile(String s3Path) {
364359 }
365360
366361 Promise <Void > promise = Promise .promise ();
367- this .downloadExecutor .<Void >executeBlocking (
368- blockingPromise -> this .cloudDownloadBlocking (blockingPromise , s3Path ),
369- ar -> {
362+ this .downloadExecutor .executeBlocking (() -> {
363+ this .cloudDownloadBlocking (s3Path );
364+ return null ;
365+ }, false ).onComplete (ar -> {
370366 this .pendingDownload .remove (s3Path );
371367 this .handleAsyncResult (ar );
372368 promise .complete ();
@@ -385,7 +381,7 @@ private Future<Void> cloudDownloadFile(String s3Path) {
385381 return promise .future ();
386382 }
387383
388- private void cloudDownloadBlocking (Promise < Void > promise , String s3Path ) {
384+ private void cloudDownloadBlocking (String s3Path ) throws Exception {
389385 final long cloudDownloadStart = System .nanoTime ();
390386 try {
391387 String localPath = this .cloudSync .toLocalPath (s3Path );
@@ -398,15 +394,14 @@ private void cloudDownloadBlocking(Promise<Void> promise, String s3Path) {
398394 downloadSuccessTimer .record (java .time .Duration .ofMillis (cloudDownloadTimeMs ));
399395 LOGGER .info ("S3 download completed: {} in {} ms" , cloudStorage .mask (s3Path ), cloudDownloadTimeMs );
400396 }
401- promise .complete ();
402397 } catch (Exception ex ) {
403398 final long cloudDownloadEnd = System .nanoTime ();
404399 final long cloudDownloadTimeMs = (cloudDownloadEnd - cloudDownloadStart ) / 1_000_000 ;
405400
406401 downloadFailureTimer .record (java .time .Duration .ofMillis (cloudDownloadTimeMs ));
407402 // Be careful as the s3Path may contain the pre-signed S3 token, so do not log the whole path
408403 LOGGER .error ("download error: " + ex .getClass ().getSimpleName ());
409- promise . fail ( new Throwable ( ex ));
404+ throw new CloudStorageException ( "Download failed" );
410405 }
411406 }
412407
0 commit comments