Skip to content

Commit 64e3496

Browse files
committed
deprecated methods
1 parent e4ec0fe commit 64e3496

File tree

1 file changed

+21
-25
lines changed

1 file changed

+21
-25
lines changed

src/main/java/com/uid2/shared/vertx/CloudSyncVerticle.java

Lines changed: 21 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -232,16 +232,17 @@ 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 -> {
242242
this.isRefreshing = false;
243243
emitRefreshedEvent();
244244
});
245+
245246
}
246247

247248
// this is a blocking function
@@ -320,12 +321,13 @@ private void handleUpload(Message<String> msg) {
320321
this.pendingUpload.add(fileToUpload);
321322
}
322323

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());
324+
this.uploadExecutor.executeBlocking(() -> {
325+
this.cloudUploadBlocking(msg.body());
326+
return null;
327+
}).onComplete(ar -> {
328+
this.pendingUpload.remove(fileToUpload);
329+
this.handleAsyncResult(ar);
330+
msg.reply(ar.succeeded());
329331

330332
// increase counter
331333
if (ar.succeeded()) {
@@ -338,16 +340,10 @@ private void handleUpload(Message<String> msg) {
338340
});
339341
}
340342

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));
343+
private void cloudUploadBlocking(String fileToUpload) throws Exception {
344+
String cloudPath = this.cloudSync.toCloudPath(fileToUpload);
345+
try (InputStream localInput = this.localStorage.download(fileToUpload)) {
346+
this.cloudStorage.upload(localInput, cloudPath);
351347
}
352348
}
353349

@@ -364,9 +360,10 @@ private Future<Void> cloudDownloadFile(String s3Path) {
364360
}
365361

366362
Promise<Void> promise = Promise.promise();
367-
this.downloadExecutor.<Void>executeBlocking(
368-
blockingPromise -> this.cloudDownloadBlocking(blockingPromise, s3Path),
369-
ar -> {
363+
this.downloadExecutor.executeBlocking(() -> {
364+
this.cloudDownloadBlocking(s3Path);
365+
return null;
366+
}).onComplete(ar -> {
370367
this.pendingDownload.remove(s3Path);
371368
this.handleAsyncResult(ar);
372369
promise.complete();
@@ -385,7 +382,7 @@ private Future<Void> cloudDownloadFile(String s3Path) {
385382
return promise.future();
386383
}
387384

388-
private void cloudDownloadBlocking(Promise<Void> promise, String s3Path) {
385+
private void cloudDownloadBlocking(String s3Path) throws Exception {
389386
final long cloudDownloadStart = System.nanoTime();
390387
try {
391388
String localPath = this.cloudSync.toLocalPath(s3Path);
@@ -398,15 +395,14 @@ private void cloudDownloadBlocking(Promise<Void> promise, String s3Path) {
398395
downloadSuccessTimer.record(java.time.Duration.ofMillis(cloudDownloadTimeMs));
399396
LOGGER.info("S3 download completed: {} in {} ms", cloudStorage.mask(s3Path), cloudDownloadTimeMs);
400397
}
401-
promise.complete();
402398
} catch (Exception ex) {
403399
final long cloudDownloadEnd = System.nanoTime();
404400
final long cloudDownloadTimeMs = (cloudDownloadEnd - cloudDownloadStart) / 1_000_000;
405401

406402
downloadFailureTimer.record(java.time.Duration.ofMillis(cloudDownloadTimeMs));
407403
// Be careful as the s3Path may contain the pre-signed S3 token, so do not log the whole path
408404
LOGGER.error("download error: " + ex.getClass().getSimpleName());
409-
promise.fail(new Throwable(ex));
405+
throw ex;
410406
}
411407
}
412408

0 commit comments

Comments
 (0)