diff --git a/src/main/java/org/prebid/server/analytics/AnalyticsReporterDelegator.java b/src/main/java/org/prebid/server/analytics/AnalyticsReporterDelegator.java index 5ab765aceb4..4da8f31d769 100644 --- a/src/main/java/org/prebid/server/analytics/AnalyticsReporterDelegator.java +++ b/src/main/java/org/prebid/server/analytics/AnalyticsReporterDelegator.java @@ -76,7 +76,7 @@ public void processEvent(T event) { public void processEvent(T event, TcfContext tcfContext) { privacyEnforcementService.resultForVendorIds(reporterVendorIds, tcfContext) - .setHandler(privacyEnforcementMap -> delegateEvent(event, tcfContext, privacyEnforcementMap)); + .onComplete(privacyEnforcementMap -> delegateEvent(event, tcfContext, privacyEnforcementMap)); } private void delegateEvent(T event, diff --git a/src/main/java/org/prebid/server/analytics/pubstack/PubstackAnalyticsReporter.java b/src/main/java/org/prebid/server/analytics/pubstack/PubstackAnalyticsReporter.java index 0c3c81f1d08..2f068951c7a 100644 --- a/src/main/java/org/prebid/server/analytics/pubstack/PubstackAnalyticsReporter.java +++ b/src/main/java/org/prebid/server/analytics/pubstack/PubstackAnalyticsReporter.java @@ -126,7 +126,7 @@ private void fetchRemoteConfig() { logger.info("[pubstack] Updating config: {0}", pubstackConfig); httpClient.get(makeEventEndpointUrl(pubstackConfig.getEndpoint(), pubstackConfig.getScopeId()), timeout) .map(this::processRemoteConfigurationResponse) - .setHandler(this::updateConfigsOnChange); + .onComplete(this::updateConfigsOnChange); } private PubstackConfig processRemoteConfigurationResponse(HttpClientResponse response) { diff --git a/src/main/java/org/prebid/server/analytics/pubstack/PubstackEventHandler.java b/src/main/java/org/prebid/server/analytics/pubstack/PubstackEventHandler.java index 9dda0492e62..20f8ee8dff6 100644 --- a/src/main/java/org/prebid/server/analytics/pubstack/PubstackEventHandler.java +++ b/src/main/java/org/prebid/server/analytics/pubstack/PubstackEventHandler.java @@ -134,7 +134,7 @@ private void sendEvents(AtomicReference> events) { resetReportEventsConditions(); httpClient.request(HttpMethod.POST, url, headers, toGzippedBytes(copyToSend), timeoutMs) - .setHandler(this::handleReportResponse); + .onComplete(this::handleReportResponse); } private void resetReportEventsConditions() { diff --git a/src/main/java/org/prebid/server/auction/categorymapping/BasicCategoryMappingService.java b/src/main/java/org/prebid/server/auction/categorymapping/BasicCategoryMappingService.java index 5ba917e4a54..ea0b906ec1d 100644 --- a/src/main/java/org/prebid/server/auction/categorymapping/BasicCategoryMappingService.java +++ b/src/main/java/org/prebid/server/auction/categorymapping/BasicCategoryMappingService.java @@ -158,7 +158,7 @@ private Future> makeBidderToBidCategory(List + compositeFuture.onComplete(ignored -> collectCategoryFetchResults(compositeFuture, categoryBidContextsPromise, rejectedBids)); return categoryBidContextsPromise.future(); diff --git a/src/main/java/org/prebid/server/deals/AlertHttpService.java b/src/main/java/org/prebid/server/deals/AlertHttpService.java index 1abfb3d21d7..a77f221f315 100644 --- a/src/main/java/org/prebid/server/deals/AlertHttpService.java +++ b/src/main/java/org/prebid/server/deals/AlertHttpService.java @@ -109,7 +109,7 @@ public void alert(String name, AlertPriority alertPriority, String message) { try { httpClient.post(alertProxyProperties.getUrl(), headers(), mapper.encodeToString(Collections.singletonList(alertEvent)), timeoutMillis) - .setHandler(this::handleResponse); + .onComplete(this::handleResponse); } catch (EncodeException e) { logger.warn("Can't parse alert proxy payload: {0}", e.getMessage()); } diff --git a/src/main/java/org/prebid/server/deals/DealsProcessor.java b/src/main/java/org/prebid/server/deals/DealsProcessor.java index c462667073a..fb011de0272 100644 --- a/src/main/java/org/prebid/server/deals/DealsProcessor.java +++ b/src/main/java/org/prebid/server/deals/DealsProcessor.java @@ -127,7 +127,7 @@ public Future populateDealsInfo(AuctionContext context) { // So, in handler it is ignored and original CompositeFuture used to process obtained results // to avoid explicit casting to CompositeFuture implementation. final Promise> promise = Promise.promise(); - compositeFuture.setHandler(ignored -> handleDealsInfo(compositeFuture, promise, context.getAccount().getId())); + compositeFuture.onComplete(ignored -> handleDealsInfo(compositeFuture, promise, context.getAccount().getId())); return promise.future() .map((Tuple3 tuple) -> enrichAuctionContext(context, tuple.getLeft(), tuple.getMiddle(), tuple.getRight())) diff --git a/src/main/java/org/prebid/server/deals/DeliveryStatsService.java b/src/main/java/org/prebid/server/deals/DeliveryStatsService.java index 17f4dbb7f18..0fcd7fc83b1 100644 --- a/src/main/java/org/prebid/server/deals/DeliveryStatsService.java +++ b/src/main/java/org/prebid/server/deals/DeliveryStatsService.java @@ -118,7 +118,7 @@ public void sendDeliveryProgressReports(ZonedDateTime now) { : Future.succeededFuture())), // combiner does not do any useful operations, just required for this type of reduce operation (a, b) -> Promise.promise().future()) - .setHandler(result -> handleDeliveryResult(result, batchesCount, sentBatches)); + .onComplete(result -> handleDeliveryResult(result, batchesCount, sentBatches)); } protected Future sendBatch(DeliveryProgressReportBatch deliveryProgressReportBatch, ZonedDateTime now) { @@ -136,7 +136,7 @@ protected Future sendBatch(DeliveryProgressReportBatch deliveryProgressRep ? setInterval(reportIntervalMs) : Future.succeededFuture()), (a, b) -> Promise.promise().future()) - .setHandler(result -> handleBatchDelivery(result, deliveryProgressReportBatch, sentReports, promise)); + .onComplete(result -> handleBatchDelivery(result, deliveryProgressReportBatch, sentReports, promise)); return promise.future(); } @@ -160,12 +160,12 @@ protected Future sendReport(DeliveryProgressReport deliveryProgressReport, headers.add(HttpHeaders.CONTENT_ENCODING, GZIP); httpClient.request(HttpMethod.POST, deliveryStatsProperties.getEndpoint(), headers, gzipBody(body), deliveryStatsProperties.getTimeoutMs()) - .setHandler(result -> handleDeliveryProgressReport(result, deliveryProgressReport, promise, + .onComplete(result -> handleDeliveryProgressReport(result, deliveryProgressReport, promise, startTime)); } else { httpClient.post(deliveryStatsProperties.getEndpoint(), headers, body, deliveryStatsProperties.getTimeoutMs()) - .setHandler(result -> handleDeliveryProgressReport(result, deliveryProgressReport, promise, + .onComplete(result -> handleDeliveryProgressReport(result, deliveryProgressReport, promise, startTime)); } diff --git a/src/main/java/org/prebid/server/deals/PlannerService.java b/src/main/java/org/prebid/server/deals/PlannerService.java index 042989de460..af61f2e3561 100644 --- a/src/main/java/org/prebid/server/deals/PlannerService.java +++ b/src/main/java/org/prebid/server/deals/PlannerService.java @@ -186,7 +186,7 @@ public void updateLineItemMetaData() { final MultiMap headers = headers(); fetchLineItemMetaData(planEndpoint, headers) .recover(ignored -> startRecoveryProcess(planEndpoint, headers)) - .setHandler(this::handleInitializationResult); + .onComplete(this::handleInitializationResult); } private Future> startRecoveryProcess(String planEndpoint, MultiMap headers) { diff --git a/src/main/java/org/prebid/server/deals/RegisterService.java b/src/main/java/org/prebid/server/deals/RegisterService.java index baaaf56236f..10671fbb0aa 100644 --- a/src/main/java/org/prebid/server/deals/RegisterService.java +++ b/src/main/java/org/prebid/server/deals/RegisterService.java @@ -139,7 +139,7 @@ protected void register(MultiMap headers) { logger.debug("Register request payload: {0}", body); httpClient.post(plannerProperties.getRegisterEndpoint(), headers, body, registerTimeout) - .setHandler(this::handleRegister); + .onComplete(this::handleRegister); } protected MultiMap headers() { diff --git a/src/main/java/org/prebid/server/deals/UserService.java b/src/main/java/org/prebid/server/deals/UserService.java index 3a445d4159c..16f133e3b71 100644 --- a/src/main/java/org/prebid/server/deals/UserService.java +++ b/src/main/java/org/prebid/server/deals/UserService.java @@ -247,7 +247,7 @@ public void processWinEvent(String lineItemId, String bidId, UidsCookie uids) { metrics.updateWinNotificationMetric(); final long startTime = clock.millis(); httpClient.post(winEventUrl, body, timeout) - .setHandler(result -> handleWinResponse(result, startTime)); + .onComplete(result -> handleWinResponse(result, startTime)); } /** diff --git a/src/main/java/org/prebid/server/deals/simulation/SimulationAwarePlannerService.java b/src/main/java/org/prebid/server/deals/simulation/SimulationAwarePlannerService.java index 9ad770b96f4..2009f94e63f 100644 --- a/src/main/java/org/prebid/server/deals/simulation/SimulationAwarePlannerService.java +++ b/src/main/java/org/prebid/server/deals/simulation/SimulationAwarePlannerService.java @@ -73,7 +73,7 @@ public void advancePlans(ZonedDateTime now) { public void initiateLineItemsFetching(ZonedDateTime now) { fetchLineItemMetaData(planEndpoint, headers(now)) - .setHandler(this::handleInitializationResult); + .onComplete(this::handleInitializationResult); } /** diff --git a/src/main/java/org/prebid/server/execution/RemoteFileSyncer.java b/src/main/java/org/prebid/server/execution/RemoteFileSyncer.java index dc71788274e..ca0124015e5 100644 --- a/src/main/java/org/prebid/server/execution/RemoteFileSyncer.java +++ b/src/main/java/org/prebid/server/execution/RemoteFileSyncer.java @@ -97,12 +97,12 @@ private static void createAndCheckWritePermissionsFor(FileSystem fileSystem, Str * Fetches remote file and executes given callback with filepath on finish. */ public void syncForFilepath(RemoteFileProcessor remoteFileProcessor) { - downloadIfNotExist(remoteFileProcessor).setHandler(syncResult -> handleSync(remoteFileProcessor, syncResult)); + downloadIfNotExist(remoteFileProcessor).onComplete(syncResult -> handleSync(remoteFileProcessor, syncResult)); } private Future downloadIfNotExist(RemoteFileProcessor fileProcessor) { final Promise promise = Promise.promise(); - checkFileExist(saveFilePath).setHandler(existResult -> + checkFileExist(saveFilePath).onComplete(existResult -> handleFileExistingWithSync(existResult, fileProcessor, promise)); return promise.future(); } @@ -124,9 +124,9 @@ private void handleFileExistingWithSync(AsyncResult existResult, Remote if (existResult.succeeded()) { if (existResult.result()) { fileProcessor.setDataPath(saveFilePath) - .setHandler(serviceRespond -> handleServiceRespond(serviceRespond, promise)); + .onComplete(serviceRespond -> handleServiceRespond(serviceRespond, promise)); } else { - syncRemoteFiles().setHandler(promise); + syncRemoteFiles().onComplete(promise); } } else { promise.fail(existResult.cause()); @@ -136,7 +136,7 @@ private void handleFileExistingWithSync(AsyncResult existResult, Remote private void handleServiceRespond(AsyncResult processResult, Promise promise) { if (processResult.failed()) { final Throwable cause = processResult.cause(); - cleanUp(saveFilePath).setHandler(removalResult -> handleCorruptedFileRemoval(removalResult, promise, + cleanUp(saveFilePath).onComplete(removalResult -> handleCorruptedFileRemoval(removalResult, promise, cause)); } else { promise.complete(false); @@ -146,7 +146,7 @@ private void handleServiceRespond(AsyncResult processResult, Promise private Future cleanUp(String filePath) { final Promise promise = Promise.promise(); - checkFileExist(filePath).setHandler(existResult -> handleFileExistsWithDelete(filePath, existResult, promise)); + checkFileExist(filePath).onComplete(existResult -> handleFileExistsWithDelete(filePath, existResult, promise)); return promise.future(); } @@ -173,7 +173,7 @@ private void handleCorruptedFileRemoval( logger.info("Existing file {0} cant be processed by service, try to download after removal", serviceCause, saveFilePath); - syncRemoteFiles().setHandler(promise); + syncRemoteFiles().onComplete(promise); } } @@ -185,7 +185,7 @@ private Future syncRemoteFiles() { private Future tryDownload() { final Promise promise = Promise.promise(); - cleanUp(tmpFilePath).setHandler(event -> handleTmpDelete(event, promise)); + cleanUp(tmpFilePath).onComplete(event -> handleTmpDelete(event, promise)); return promise.future(); } @@ -193,7 +193,7 @@ private void handleTmpDelete(AsyncResult tmpDeleteResult, Promise pr if (tmpDeleteResult.failed()) { promise.fail(tmpDeleteResult.cause()); } else { - download().setHandler(downloadResult -> handleDownload(downloadResult, promise)); + download().onComplete(downloadResult -> handleDownload(downloadResult, promise)); } } @@ -265,9 +265,9 @@ private void handleRetry(Promise receivedPromise, long retryInterval, long if (retryCount > 0) { final long next = retryCount - 1; cleanUp(tmpFilePath).compose(ignore -> download()) - .setHandler(retryResult -> handleRetryResult(retryInterval, next, retryResult, receivedPromise)); + .onComplete(retryResult -> handleRetryResult(retryInterval, next, retryResult, receivedPromise)); } else { - cleanUp(tmpFilePath).setHandler(ignore -> receivedPromise.fail(new PreBidException( + cleanUp(tmpFilePath).onComplete(ignore -> receivedPromise.fail(new PreBidException( String.format("File sync failed after %s retries", this.retryCount - retryCount)))); } } @@ -295,7 +295,7 @@ private void handleSync(RemoteFileProcessor remoteFileProcessor, AsyncResult serviceRespond) { private void configureAutoUpdates(RemoteFileProcessor remoteFileProcessor) { logger.info("Check for updated for {0}", saveFilePath); - tryUpdate().setHandler(asyncUpdate -> { + tryUpdate().onComplete(asyncUpdate -> { if (asyncUpdate.failed()) { logger.warn("File {0} update failed", asyncUpdate.cause(), saveFilePath); } diff --git a/src/main/java/org/prebid/server/geolocation/CircuitBreakerSecuredGeoLocationService.java b/src/main/java/org/prebid/server/geolocation/CircuitBreakerSecuredGeoLocationService.java index be6bcf20ac6..f7a2c6ca6b9 100755 --- a/src/main/java/org/prebid/server/geolocation/CircuitBreakerSecuredGeoLocationService.java +++ b/src/main/java/org/prebid/server/geolocation/CircuitBreakerSecuredGeoLocationService.java @@ -49,7 +49,7 @@ public CircuitBreakerSecuredGeoLocationService(Vertx vertx, @Override public Future lookup(String ip, Timeout timeout) { - return breaker.execute(promise -> geoLocationService.lookup(ip, timeout).setHandler(promise)); + return breaker.execute(promise -> geoLocationService.lookup(ip, timeout).onComplete(promise)); } private void circuitOpened() { diff --git a/src/main/java/org/prebid/server/handler/CookieSyncHandler.java b/src/main/java/org/prebid/server/handler/CookieSyncHandler.java index 6471bc3426f..7898ed28e7e 100644 --- a/src/main/java/org/prebid/server/handler/CookieSyncHandler.java +++ b/src/main/java/org/prebid/server/handler/CookieSyncHandler.java @@ -150,7 +150,7 @@ public void handle(RoutingContext routingContext) { metrics.updateCookieSyncRequestMetric(); toCookieSyncContext(routingContext) - .setHandler(cookieSyncContextResult -> handleCookieSyncContextResult(cookieSyncContextResult, + .onComplete(cookieSyncContextResult -> handleCookieSyncContextResult(cookieSyncContextResult, routingContext)); } @@ -218,7 +218,7 @@ private void handleCookieSyncContextResult(AsyncResult cookie } isAllowedForHostVendorId(tcfContext) - .setHandler(hostTcfResponseResult -> respondByTcfResponse( + .onComplete(hostTcfResponseResult -> respondByTcfResponse( hostTcfResponseResult, biddersToSync(cookieSyncContext), cookieSyncContext)); @@ -365,7 +365,7 @@ private void respondByTcfResponse(AsyncResult hostTcfResp final AccountGdprConfig accountGdprConfig = accountPrivacyConfig != null ? accountPrivacyConfig.getGdpr() : null; tcfDefinerService.resultForBidderNames(biddersToSync, tcfContext, accountGdprConfig) - .setHandler(tcfResponseResult -> respondByTcfResultForBidders(tcfResponseResult, + .onComplete(tcfResponseResult -> respondByTcfResultForBidders(tcfResponseResult, biddersToSync, cookieSyncContext)); } else { // Reject all bidders when Host TCF response has blocked pixel diff --git a/src/main/java/org/prebid/server/handler/NotificationEventHandler.java b/src/main/java/org/prebid/server/handler/NotificationEventHandler.java index a22b080912a..2a9dda4ef65 100644 --- a/src/main/java/org/prebid/server/handler/NotificationEventHandler.java +++ b/src/main/java/org/prebid/server/handler/NotificationEventHandler.java @@ -110,7 +110,7 @@ public void handle(RoutingContext routingContext) { final EventRequest eventRequest = EventUtil.from(routingContext); getAccountById(eventRequest.getAccountId()) - .setHandler(async -> handleEvent(async, eventRequest, routingContext)); + .onComplete(async -> handleEvent(async, eventRequest, routingContext)); } /** diff --git a/src/main/java/org/prebid/server/handler/OptoutHandler.java b/src/main/java/org/prebid/server/handler/OptoutHandler.java index 35cb2748070..eb1a5acc725 100644 --- a/src/main/java/org/prebid/server/handler/OptoutHandler.java +++ b/src/main/java/org/prebid/server/handler/OptoutHandler.java @@ -50,7 +50,7 @@ public void handle(RoutingContext routingContext) { } googleRecaptchaVerifier.verify(recaptcha) - .setHandler(result -> handleVerification(routingContext, result)); + .onComplete(result -> handleVerification(routingContext, result)); } private void handleVerification(RoutingContext routingContext, AsyncResult result) { diff --git a/src/main/java/org/prebid/server/handler/SetuidHandler.java b/src/main/java/org/prebid/server/handler/SetuidHandler.java index 570eab328fe..361c3388433 100644 --- a/src/main/java/org/prebid/server/handler/SetuidHandler.java +++ b/src/main/java/org/prebid/server/handler/SetuidHandler.java @@ -107,7 +107,7 @@ private static String preferredUserSyncType(Usersyncer usersyncer) { @Override public void handle(RoutingContext routingContext) { toSetuidContext(routingContext) - .setHandler(setuidContextResult -> handleSetuidContextResult(setuidContextResult, routingContext)); + .onComplete(setuidContextResult -> handleSetuidContextResult(setuidContextResult, routingContext)); } private Future toSetuidContext(RoutingContext routingContext) { @@ -152,7 +152,7 @@ private void handleSetuidContextResult(AsyncResult setuidContextR } isAllowedForHostVendorId(tcfContext) - .setHandler(hostTcfResponseResult -> respondByTcfResponse(hostTcfResponseResult, setuidContext)); + .onComplete(hostTcfResponseResult -> respondByTcfResponse(hostTcfResponseResult, setuidContext)); } else { final Throwable error = setuidContextResult.cause(); handleErrors(error, routingContext, null); diff --git a/src/main/java/org/prebid/server/handler/VtrackHandler.java b/src/main/java/org/prebid/server/handler/VtrackHandler.java index b0aa382f482..0892e0061ca 100644 --- a/src/main/java/org/prebid/server/handler/VtrackHandler.java +++ b/src/main/java/org/prebid/server/handler/VtrackHandler.java @@ -89,7 +89,7 @@ public void handle(RoutingContext routingContext) { applicationSettings.getAccountById(accountId, timeout) .recover(exception -> handleAccountExceptionOrFallback(exception, accountId)) - .setHandler(async -> handleAccountResult(async, routingContext, vtrackPuts, accountId, integration, + .onComplete(async -> handleAccountResult(async, routingContext, vtrackPuts, accountId, integration, timeout)); } @@ -176,7 +176,7 @@ private void handleAccountResult(AsyncResult asyncAccount, final Boolean isEventEnabled = accountEventsEnabled(asyncAccount.result()); final Set allowedBidders = biddersAllowingVastUpdate(vtrackPuts); cacheService.cachePutObjects(vtrackPuts, isEventEnabled, allowedBidders, accountId, integration, timeout) - .setHandler(asyncCache -> handleCacheResult(asyncCache, routingContext)); + .onComplete(asyncCache -> handleCacheResult(asyncCache, routingContext)); } } diff --git a/src/main/java/org/prebid/server/handler/openrtb2/AmpHandler.java b/src/main/java/org/prebid/server/handler/openrtb2/AmpHandler.java index f6500b7cc60..34628146ce8 100644 --- a/src/main/java/org/prebid/server/handler/openrtb2/AmpHandler.java +++ b/src/main/java/org/prebid/server/handler/openrtb2/AmpHandler.java @@ -132,7 +132,7 @@ public void handle(RoutingContext routingContext) { .map(context -> addToEvent(context.getBidResponse(), ampEventBuilder::bidResponse, context)) .compose(context -> prepareAmpResponse(context, routingContext)) .map(result -> addToEvent(result.getLeft().getTargeting(), ampEventBuilder::targeting, result)) - .setHandler(responseResult -> handleResult(responseResult, ampEventBuilder, routingContext, startTime)); + .onComplete(responseResult -> handleResult(responseResult, ampEventBuilder, routingContext, startTime)); } private static R addToEvent(T field, Consumer consumer, R result) { diff --git a/src/main/java/org/prebid/server/handler/openrtb2/AuctionHandler.java b/src/main/java/org/prebid/server/handler/openrtb2/AuctionHandler.java index 7bc83e5d3f2..e056cbb2305 100644 --- a/src/main/java/org/prebid/server/handler/openrtb2/AuctionHandler.java +++ b/src/main/java/org/prebid/server/handler/openrtb2/AuctionHandler.java @@ -94,7 +94,7 @@ public void handle(RoutingContext routingContext) { // populate event with updated context .map(context -> addToEvent(context, auctionEventBuilder::auctionContext, context)) .map(context -> addToEvent(context.getBidResponse(), auctionEventBuilder::bidResponse, context)) - .setHandler(context -> handleResult(context, auctionEventBuilder, routingContext, startTime)); + .onComplete(context -> handleResult(context, auctionEventBuilder, routingContext, startTime)); } private static R addToEvent(T field, Consumer consumer, R result) { diff --git a/src/main/java/org/prebid/server/handler/openrtb2/VideoHandler.java b/src/main/java/org/prebid/server/handler/openrtb2/VideoHandler.java index 7ae6cca9ab0..e8050e79d9a 100644 --- a/src/main/java/org/prebid/server/handler/openrtb2/VideoHandler.java +++ b/src/main/java/org/prebid/server/handler/openrtb2/VideoHandler.java @@ -102,7 +102,7 @@ public void handle(RoutingContext routingContext) { result.getPodErrors())) .map(videoResponse -> addToEvent(videoResponse, videoEventBuilder::bidResponse, videoResponse)) - .setHandler(responseResult -> handleResult(responseResult, videoEventBuilder, routingContext, + .onComplete(responseResult -> handleResult(responseResult, videoEventBuilder, routingContext, startTime)); } diff --git a/src/main/java/org/prebid/server/health/DatabaseHealthChecker.java b/src/main/java/org/prebid/server/health/DatabaseHealthChecker.java index a0b1c9e61eb..e27a72dd0db 100644 --- a/src/main/java/org/prebid/server/health/DatabaseHealthChecker.java +++ b/src/main/java/org/prebid/server/health/DatabaseHealthChecker.java @@ -38,7 +38,7 @@ public String name() { void updateStatus() { final Promise connectionPromise = Promise.promise(); jdbcClient.getConnection(connectionPromise); - connectionPromise.future().setHandler(result -> + connectionPromise.future().onComplete(result -> status = StatusResponse.of( result.succeeded() ? Status.UP.name() : Status.DOWN.name(), ZonedDateTime.now(Clock.systemUTC()))); diff --git a/src/main/java/org/prebid/server/health/GeoLocationHealthChecker.java b/src/main/java/org/prebid/server/health/GeoLocationHealthChecker.java index d0a6e33cace..6243f9ed8c7 100644 --- a/src/main/java/org/prebid/server/health/GeoLocationHealthChecker.java +++ b/src/main/java/org/prebid/server/health/GeoLocationHealthChecker.java @@ -37,7 +37,7 @@ public GeoLocationHealthChecker(Vertx vertx, @Override void updateStatus() { geoLocationService.lookup(PREBID_ORG_IP, timeoutFactory.create(TIMEOUT_MILLIS)) - .setHandler(result -> + .onComplete(result -> status = StatusResponse.of( result.succeeded() ? Status.UP.name() : Status.DOWN.name(), ZonedDateTime.now(clock))); diff --git a/src/main/java/org/prebid/server/hooks/execution/GroupExecutor.java b/src/main/java/org/prebid/server/hooks/execution/GroupExecutor.java index 3133028dfbf..cba101af232 100644 --- a/src/main/java/org/prebid/server/hooks/execution/GroupExecutor.java +++ b/src/main/java/org/prebid/server/hooks/execution/GroupExecutor.java @@ -120,7 +120,7 @@ private Future executeWithTimeout(Supplier> action, Long timeou final long timeoutTimerId = vertx.setTimer(timeout, id -> failWithTimeout(promise)); executeSafely(action) - .setHandler(result -> completeWithActionResult(promise, timeoutTimerId, result)); + .onComplete(result -> completeWithActionResult(promise, timeoutTimerId, result)); return promise.future(); } diff --git a/src/main/java/org/prebid/server/spring/config/SettingsConfiguration.java b/src/main/java/org/prebid/server/spring/config/SettingsConfiguration.java index f44c8af2fa0..c9c35a44739 100644 --- a/src/main/java/org/prebid/server/spring/config/SettingsConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/SettingsConfiguration.java @@ -125,7 +125,7 @@ private static BasicJdbcClient createBasicJdbcClient( Vertx vertx, JDBCClient vertxJdbcClient, Metrics metrics, Clock clock, ContextRunner contextRunner) { final BasicJdbcClient basicJdbcClient = new BasicJdbcClient(vertx, vertxJdbcClient, metrics, clock); - contextRunner.runOnServiceContext(promise -> basicJdbcClient.initialize().setHandler(promise)); + contextRunner.runOnServiceContext(promise -> basicJdbcClient.initialize().onComplete(promise)); return basicJdbcClient; } diff --git a/src/main/java/org/prebid/server/vertx/ContextRunner.java b/src/main/java/org/prebid/server/vertx/ContextRunner.java index 19229ec1b8c..c878ad0afc9 100644 --- a/src/main/java/org/prebid/server/vertx/ContextRunner.java +++ b/src/main/java/org/prebid/server/vertx/ContextRunner.java @@ -57,7 +57,7 @@ private void runOnContext(Supplier contextFactory, int times, Handl final Context context = contextFactory.get(); final Promise promise = Promise.promise(); - promise.future().setHandler(ar -> { + promise.future().onComplete(ar -> { if (ar.failed()) { logger.fatal("Fatal error occurred while running action on Vertx context", ar.cause()); actionFailed.compareAndSet(false, true); diff --git a/src/main/java/org/prebid/server/vertx/http/CircuitBreakerSecuredHttpClient.java b/src/main/java/org/prebid/server/vertx/http/CircuitBreakerSecuredHttpClient.java index ff8f9a52e9a..b570e019416 100644 --- a/src/main/java/org/prebid/server/vertx/http/CircuitBreakerSecuredHttpClient.java +++ b/src/main/java/org/prebid/server/vertx/http/CircuitBreakerSecuredHttpClient.java @@ -68,14 +68,14 @@ public Future request(HttpMethod method, long timeoutMs) { return circuitBreakerByName.computeIfAbsent(nameFrom(url), circuitBreakerCreator) - .execute(promise -> httpClient.request(method, url, headers, body, timeoutMs).setHandler(promise)); + .execute(promise -> httpClient.request(method, url, headers, body, timeoutMs).onComplete(promise)); } @Override public Future request(HttpMethod method, String url, MultiMap headers, byte[] body, long timeoutMs) { return circuitBreakerByName.computeIfAbsent(nameFrom(url), circuitBreakerCreator) - .execute(promise -> httpClient.request(method, url, headers, body, timeoutMs).setHandler(promise)); + .execute(promise -> httpClient.request(method, url, headers, body, timeoutMs).onComplete(promise)); } private CircuitBreaker createCircuitBreaker(String name, diff --git a/src/main/java/org/prebid/server/vertx/jdbc/BasicJdbcClient.java b/src/main/java/org/prebid/server/vertx/jdbc/BasicJdbcClient.java index f536ca4b4b8..71fd24bd166 100644 --- a/src/main/java/org/prebid/server/vertx/jdbc/BasicJdbcClient.java +++ b/src/main/java/org/prebid/server/vertx/jdbc/BasicJdbcClient.java @@ -71,7 +71,7 @@ public Future executeQuery(String query, List params, Function makeQuery(connection, query, params)) - .setHandler(result -> handleResult(result, queryResultPromise, timerId, startTime)); + .onComplete(result -> handleResult(result, queryResultPromise, timerId, startTime)); return queryResultPromise.future().map(mapper); } diff --git a/src/main/java/org/prebid/server/vertx/jdbc/CircuitBreakerSecuredJdbcClient.java b/src/main/java/org/prebid/server/vertx/jdbc/CircuitBreakerSecuredJdbcClient.java index b50b58977cc..be662e057c9 100644 --- a/src/main/java/org/prebid/server/vertx/jdbc/CircuitBreakerSecuredJdbcClient.java +++ b/src/main/java/org/prebid/server/vertx/jdbc/CircuitBreakerSecuredJdbcClient.java @@ -60,7 +60,7 @@ public Future executeQuery(String query, Function mapper, Timeout timeout) { - return breaker.execute(promise -> jdbcClient.executeQuery(query, params, mapper, timeout).setHandler(promise)); + return breaker.execute(promise -> jdbcClient.executeQuery(query, params, mapper, timeout).onComplete(promise)); } private void circuitOpened() { diff --git a/src/test/java/org/prebid/server/geolocation/CircuitBreakerSecuredGeoLocationServiceTest.java b/src/test/java/org/prebid/server/geolocation/CircuitBreakerSecuredGeoLocationServiceTest.java index 563816e8955..f7db104fad1 100644 --- a/src/test/java/org/prebid/server/geolocation/CircuitBreakerSecuredGeoLocationServiceTest.java +++ b/src/test/java/org/prebid/server/geolocation/CircuitBreakerSecuredGeoLocationServiceTest.java @@ -217,7 +217,7 @@ private Future doLookup(TestContext context) { final Async async = context.async(); final Future future = geoLocationService.lookup(null, null); - future.setHandler(ar -> async.complete()); + future.onComplete(ar -> async.complete()); async.await(); return future; diff --git a/src/test/java/org/prebid/server/hooks/execution/HookStageExecutorTest.java b/src/test/java/org/prebid/server/hooks/execution/HookStageExecutorTest.java index 323a140cbac..f25afac5ba8 100644 --- a/src/test/java/org/prebid/server/hooks/execution/HookStageExecutorTest.java +++ b/src/test/java/org/prebid/server/hooks/execution/HookStageExecutorTest.java @@ -269,7 +269,7 @@ public void shouldExecuteEntrypointHooksHappyPath(TestContext context) { // then final Async async = context.async(); - future.setHandler(context.asyncAssertSuccess(result -> { + future.onComplete(context.asyncAssertSuccess(result -> { assertThat(result).isNotNull(); assertThat(result.isShouldReject()).isFalse(); assertThat(result.getPayload()).isNotNull().satisfies(payload -> @@ -349,7 +349,7 @@ public void shouldBypassEntrypointHooksWhenNoPlanForEndpoint(TestContext context // then final Async async = context.async(); - future.setHandler(context.asyncAssertSuccess(result -> { + future.onComplete(context.asyncAssertSuccess(result -> { assertThat(result.getPayload()).satisfies(payload -> assertThat(payload.body()).isEqualTo("body")); @@ -384,7 +384,7 @@ public void shouldBypassEntrypointHooksWhenNoPlanForStage(TestContext context) { // then final Async async = context.async(); - future.setHandler(context.asyncAssertSuccess(result -> { + future.onComplete(context.asyncAssertSuccess(result -> { assertThat(result.getPayload()).satisfies(payload -> assertThat(payload.body()).isEqualTo("body")); @@ -445,7 +445,7 @@ public void shouldExecuteEntrypointHooksToleratingMisbehavingHooks(TestContext c // then final Async async = context.async(); - future.setHandler(context.asyncAssertSuccess(result -> { + future.onComplete(context.asyncAssertSuccess(result -> { assertThat(result).isNotNull(); assertThat(result.getPayload()).isNotNull().satisfies(payload -> assertThat(payload.body()).isEqualTo("body-jkl")); @@ -560,7 +560,7 @@ public void shouldExecuteEntrypointHooksToleratingTimeoutAndFailedFuture(TestCon // then final Async async = context.async(); - future.setHandler(context.asyncAssertSuccess(result -> { + future.onComplete(context.asyncAssertSuccess(result -> { assertThat(result).isNotNull(); assertThat(result.getPayload()).isNotNull().satisfies(payload -> assertThat(payload.body()).isEqualTo("body-jkl")); @@ -662,7 +662,7 @@ public void shouldExecuteEntrypointHooksHonoringStatusAndAction(TestContext cont // then final Async async = context.async(); - future.setHandler(context.asyncAssertSuccess(result -> { + future.onComplete(context.asyncAssertSuccess(result -> { assertThat(result.getPayload()).satisfies(payload -> assertThat(payload.body()).isEqualTo("body-ghi-jkl")); @@ -753,7 +753,7 @@ public void shouldExecuteEntrypointHooksWhenRequestIsRejectedByFirstGroup(TestCo // then final Async async = context.async(); - future.setHandler(context.asyncAssertSuccess(result -> { + future.onComplete(context.asyncAssertSuccess(result -> { assertThat(result.isShouldReject()).isTrue(); assertThat(result.getPayload()).isNull(); @@ -833,7 +833,7 @@ public void shouldExecuteEntrypointHooksWhenRequestIsRejectedBySecondGroup(TestC // then final Async async = context.async(); - future.setHandler(context.asyncAssertSuccess(result -> { + future.onComplete(context.asyncAssertSuccess(result -> { assertThat(result.isShouldReject()).isTrue(); assertThat(result.getPayload()).isNull(); @@ -936,7 +936,7 @@ public void shouldExecuteEntrypointHooksToleratingMisbehavingInvocationResult(Te // then final Async async = context.async(); - future.setHandler(context.asyncAssertSuccess(result -> { + future.onComplete(context.asyncAssertSuccess(result -> { assertThat(result.getPayload()).isNotNull().satisfies(payload -> assertThat(payload.body()).isEqualTo("body")); @@ -1033,7 +1033,7 @@ public void shouldExecuteEntrypointHooksAndStoreResultInExecutionContext(TestCon // then final Async async = context.async(); - future.setHandler(context.asyncAssertSuccess(result -> { + future.onComplete(context.asyncAssertSuccess(result -> { assertThat(hookExecutionContext.getStageOutcomes()) .hasEntrySatisfying( Stage.entrypoint, @@ -1090,7 +1090,7 @@ public void shouldExecuteEntrypointHooksAndPassInvocationContext(TestContext con // then final Async async = context.async(); - future.setHandler(context.asyncAssertSuccess(result -> { + future.onComplete(context.asyncAssertSuccess(result -> { final ArgumentCaptor invocationContextCaptor = ArgumentCaptor.forClass(InvocationContext.class); verify(hookImpl, times(4)).call(any(), invocationContextCaptor.capture()); @@ -1158,7 +1158,7 @@ public void shouldExecuteRawAuctionRequestHooksWhenNoExecutionPlanInAccount(Test // then final Async async = context.async(); - future.setHandler(context.asyncAssertSuccess(result -> { + future.onComplete(context.asyncAssertSuccess(result -> { assertThat(result.getPayload()).isNotNull().satisfies(payload -> assertThat(payload.bidRequest()).isSameAs(bidRequest)); @@ -1217,7 +1217,7 @@ public void shouldExecuteRawAuctionRequestHooksWhenAccountOverridesExecutionPlan // then final Async async = context.async(); - future.setHandler(context.asyncAssertSuccess(result -> { + future.onComplete(context.asyncAssertSuccess(result -> { assertThat(result.getPayload()).isNotNull().satisfies(payload -> assertThat(payload.bidRequest()).isSameAs(bidRequest)); @@ -1276,7 +1276,7 @@ public void shouldExecuteRawAuctionRequestHooksToleratingUnknownHookInAccountPla // then final Async async = context.async(); - future.setHandler(context.asyncAssertSuccess(result -> { + future.onComplete(context.asyncAssertSuccess(result -> { assertThat(result).isNotNull(); assertThat(result.getPayload()).isNotNull().satisfies(payload -> assertThat(payload.bidRequest()).isEqualTo(BidRequest.builder() @@ -1366,7 +1366,7 @@ public void shouldExecuteRawAuctionRequestHooksHappyPath(TestContext context) { // then final Async async = context.async(); - future.setHandler(context.asyncAssertSuccess(result -> { + future.onComplete(context.asyncAssertSuccess(result -> { assertThat(result).isNotNull(); assertThat(result.getPayload()).isNotNull().satisfies(payload -> assertThat(payload.bidRequest()).isEqualTo(BidRequest.builder() @@ -1432,7 +1432,7 @@ public void shouldExecuteRawAuctionRequestHooksAndPassAuctionInvocationContext(T // then final Async async = context.async(); - future.setHandler(context.asyncAssertSuccess(result -> { + future.onComplete(context.asyncAssertSuccess(result -> { final ArgumentCaptor invocationContextCaptor = ArgumentCaptor.forClass(AuctionInvocationContext.class); verify(hookImpl, times(4)).call(any(), invocationContextCaptor.capture()); @@ -1533,7 +1533,7 @@ public void shouldExecuteRawAuctionRequestHooksAndPassModuleContextBetweenHooks( // then final Async async = context.async(); - future.setHandler(context.asyncAssertSuccess(result -> { + future.onComplete(context.asyncAssertSuccess(result -> { final ArgumentCaptor invocationContextCaptor = ArgumentCaptor.forClass(AuctionInvocationContext.class); verify(hookImpl, times(6)).call(any(), invocationContextCaptor.capture()); @@ -1594,7 +1594,7 @@ public void shouldExecuteRawAuctionRequestHooksWhenRequestIsRejected(TestContext // then final Async async = context.async(); - future.setHandler(context.asyncAssertSuccess(result -> { + future.onComplete(context.asyncAssertSuccess(result -> { assertThat(result.isShouldReject()).isTrue(); assertThat(result.getPayload()).isNull(); @@ -1652,7 +1652,7 @@ public void shouldExecuteProcessedAuctionRequestHooksHappyPath(TestContext conte // then final Async async = context.async(); - future.setHandler(context.asyncAssertSuccess(result -> { + future.onComplete(context.asyncAssertSuccess(result -> { assertThat(result).isNotNull(); assertThat(result.getPayload()).isNotNull().satisfies(payload -> assertThat(payload.bidRequest()).isEqualTo(BidRequest.builder() @@ -1719,7 +1719,7 @@ public void shouldExecuteProcessedAuctionRequestHooksAndPassAuctionInvocationCon // then final Async async = context.async(); - future.setHandler(context.asyncAssertSuccess(result -> { + future.onComplete(context.asyncAssertSuccess(result -> { final ArgumentCaptor invocationContextCaptor = ArgumentCaptor.forClass(AuctionInvocationContext.class); verify(hookImpl, times(4)).call(any(), invocationContextCaptor.capture()); @@ -1821,7 +1821,7 @@ public void shouldExecuteProcessedAuctionRequestHooksAndPassModuleContextBetween // then final Async async = context.async(); - future.setHandler(context.asyncAssertSuccess(result -> { + future.onComplete(context.asyncAssertSuccess(result -> { final ArgumentCaptor invocationContextCaptor = ArgumentCaptor.forClass(AuctionInvocationContext.class); verify(hookImpl, times(6)).call(any(), invocationContextCaptor.capture()); @@ -1884,7 +1884,7 @@ public void shouldExecuteProcessedAuctionRequestHooksWhenRequestIsRejected(TestC // then final Async async = context.async(); - future.setHandler(context.asyncAssertSuccess(result -> { + future.onComplete(context.asyncAssertSuccess(result -> { assertThat(result.isShouldReject()).isTrue(); assertThat(result.getPayload()).isNull(); @@ -1946,7 +1946,7 @@ public void shouldExecuteBidderRequestHooksHappyPath(TestContext context) { // then final Async async = context.async(); - future1.setHandler(context.asyncAssertSuccess(result -> { + future1.onComplete(context.asyncAssertSuccess(result -> { assertThat(result).isNotNull(); assertThat(result.getPayload()).isNotNull().satisfies(payload -> assertThat(payload.bidRequest()).isEqualTo(BidRequest.builder() @@ -1959,7 +1959,7 @@ public void shouldExecuteBidderRequestHooksHappyPath(TestContext context) { async.complete(); })); - CompositeFuture.join(future1, future2).setHandler(context.asyncAssertSuccess(result -> + CompositeFuture.join(future1, future2).onComplete(context.asyncAssertSuccess(result -> assertThat(hookExecutionContext.getStageOutcomes()) .hasEntrySatisfying( Stage.bidder_request, @@ -2002,7 +2002,7 @@ null, singletonMap("module-alpha", mapper.createObjectNode()))) // then final Async async = context.async(); - future.setHandler(context.asyncAssertSuccess(result -> { + future.onComplete(context.asyncAssertSuccess(result -> { final ArgumentCaptor invocationContextCaptor = ArgumentCaptor.forClass(BidderInvocationContext.class); verify(hookImpl).call(any(), invocationContextCaptor.capture()); @@ -2101,7 +2101,7 @@ public void shouldExecuteRawBidderResponseHooksHappyPath(TestContext context) { // then final Async async = context.async(); - future1.setHandler(context.asyncAssertSuccess(result -> { + future1.onComplete(context.asyncAssertSuccess(result -> { assertThat(result).isNotNull(); assertThat(result.getPayload()).isNotNull().satisfies(payload -> assertThat(payload.bids()).containsOnly(BidderBid.of( @@ -2117,7 +2117,7 @@ public void shouldExecuteRawBidderResponseHooksHappyPath(TestContext context) { async.complete(); })); - CompositeFuture.join(future1, future2).setHandler(context.asyncAssertSuccess(result -> + CompositeFuture.join(future1, future2).onComplete(context.asyncAssertSuccess(result -> assertThat(hookExecutionContext.getStageOutcomes()) .hasEntrySatisfying( Stage.raw_bidder_response, @@ -2166,7 +2166,7 @@ null, singletonMap("module-alpha", mapper.createObjectNode()))) // then final Async async = context.async(); - future.setHandler(context.asyncAssertSuccess(result -> { + future.onComplete(context.asyncAssertSuccess(result -> { final ArgumentCaptor invocationContextCaptor = ArgumentCaptor.forClass(BidderInvocationContext.class); verify(hookImpl).call(any(), invocationContextCaptor.capture()); @@ -2267,7 +2267,7 @@ public void shouldExecuteProcessedBidderResponseHooksHappyPath(TestContext conte // then final Async async = context.async(); - future1.setHandler(context.asyncAssertSuccess(result -> { + future1.onComplete(context.asyncAssertSuccess(result -> { assertThat(result).isNotNull(); assertThat(result.getPayload()).isNotNull().satisfies(payload -> assertThat(payload.bids()).containsOnly(BidderBid.of( @@ -2283,7 +2283,7 @@ public void shouldExecuteProcessedBidderResponseHooksHappyPath(TestContext conte async.complete(); })); - CompositeFuture.join(future1, future2).setHandler(context.asyncAssertSuccess(result -> + CompositeFuture.join(future1, future2).onComplete(context.asyncAssertSuccess(result -> assertThat(hookExecutionContext.getStageOutcomes()) .hasEntrySatisfying( Stage.processed_bidder_response, @@ -2334,7 +2334,7 @@ null, singletonMap("module-alpha", mapper.createObjectNode()))) // then final Async async = context.async(); - future.setHandler(context.asyncAssertSuccess(result -> { + future.onComplete(context.asyncAssertSuccess(result -> { final ArgumentCaptor invocationContextCaptor = ArgumentCaptor.forClass(BidderInvocationContext.class); verify(hookImpl).call(any(), invocationContextCaptor.capture()); @@ -2379,7 +2379,7 @@ public void shouldExecuteBidderRequestHooksWhenRequestIsRejected(TestContext con // then final Async async = context.async(); - future.setHandler(context.asyncAssertSuccess(result -> { + future.onComplete(context.asyncAssertSuccess(result -> { assertThat(result.isShouldReject()).isTrue(); assertThat(result.getPayload()).isNull(); @@ -2437,7 +2437,7 @@ public void shouldExecuteAuctionResponseHooksHappyPath(TestContext context) { // then final Async async = context.async(); - future.setHandler(context.asyncAssertSuccess(result -> { + future.onComplete(context.asyncAssertSuccess(result -> { assertThat(result).isNotNull(); assertThat(result.getPayload()).isNotNull().satisfies(payload -> assertThat(payload.bidResponse()).isEqualTo(BidResponse.builder() @@ -2484,7 +2484,7 @@ null, singletonMap("module-alpha", mapper.createObjectNode()))) // then final Async async = context.async(); - future.setHandler(context.asyncAssertSuccess(result -> { + future.onComplete(context.asyncAssertSuccess(result -> { final ArgumentCaptor invocationContextCaptor = ArgumentCaptor.forClass(AuctionInvocationContext.class); verify(hookImpl).call(any(), invocationContextCaptor.capture()); @@ -2528,7 +2528,7 @@ public void shouldExecuteAuctionResponseHooksAndIgnoreRejection(TestContext cont // then final Async async = context.async(); - future.setHandler(context.asyncAssertSuccess(result -> { + future.onComplete(context.asyncAssertSuccess(result -> { assertThat(result.isShouldReject()).isFalse(); assertThat(result.getPayload()).isNotNull().satisfies(payload -> assertThat(payload.bidResponse()).isNotNull()); diff --git a/src/test/java/org/prebid/server/settings/JdbcApplicationSettingsTest.java b/src/test/java/org/prebid/server/settings/JdbcApplicationSettingsTest.java index 399ca66cc7e..159899bce43 100644 --- a/src/test/java/org/prebid/server/settings/JdbcApplicationSettingsTest.java +++ b/src/test/java/org/prebid/server/settings/JdbcApplicationSettingsTest.java @@ -220,7 +220,7 @@ public void getAccountByIdShouldReturnAccountWithAllFieldsPopulated(TestContext // then final Async async = context.async(); - future.setHandler(context.asyncAssertSuccess(account -> { + future.onComplete(context.asyncAssertSuccess(account -> { assertThat(account).isEqualTo(Account.builder() .id("1001") .status(AccountStatus.active) @@ -259,7 +259,7 @@ public void getAccountByIdShouldFailIfAccountNotFound(TestContext context) { // then final Async async = context.async(); - future.setHandler(context.asyncAssertFailure(exception -> { + future.onComplete(context.asyncAssertFailure(exception -> { assertThat(exception).isInstanceOf(PreBidException.class) .hasMessage("Account not found: non-existing"); async.complete(); @@ -280,7 +280,7 @@ public void getStoredDataShouldReturnExpectedResult(TestContext context) { final Map expectedImps = new HashMap<>(); expectedImps.put("4", "value4"); expectedImps.put("5", "value5"); - future.setHandler(context.asyncAssertSuccess(storedRequestResult -> { + future.onComplete(context.asyncAssertSuccess(storedRequestResult -> { assertThat(storedRequestResult) .isEqualTo(StoredDataResult.of(expectedRequests, expectedImps, emptyList())); async.complete(); @@ -298,7 +298,7 @@ public void getAmpStoredDataShouldReturnExpectedResult(TestContext context) { final Map expectedRequests = new HashMap<>(); expectedRequests.put("1", "value1"); expectedRequests.put("2", "value2"); - future.setHandler(context.asyncAssertSuccess(storedRequestResult -> { + future.onComplete(context.asyncAssertSuccess(storedRequestResult -> { assertThat(storedRequestResult) .isEqualTo(StoredDataResult.of(expectedRequests, emptyMap(), emptyList())); async.complete(); @@ -319,7 +319,7 @@ public void getVideoStoredDataShouldReturnExpectedResult(TestContext context) { final Map expectedImps = new HashMap<>(); expectedImps.put("4", "value4"); expectedImps.put("5", "value5"); - future.setHandler(context.asyncAssertSuccess(storedRequestResult -> { + future.onComplete(context.asyncAssertSuccess(storedRequestResult -> { assertThat(storedRequestResult) .isEqualTo(StoredDataResult.of(expectedRequests, expectedImps, emptyList())); async.complete(); @@ -344,7 +344,7 @@ public void getVideoStoredDataShouldReturnStoredRequests(TestContext context) { // then final Async async = context.async(); - storedRequestResultFuture.setHandler(context.asyncAssertSuccess(storedRequestResult -> { + storedRequestResultFuture.onComplete(context.asyncAssertSuccess(storedRequestResult -> { final Map expectedRequests = new HashMap<>(); expectedRequests.put("1", "value1"); expectedRequests.put("2", "value2"); @@ -377,7 +377,7 @@ public void getStoredDataUnionSelectByIdShouldReturnStoredRequests(TestContext c // then final Async async = context.async(); - storedRequestResultFuture.setHandler(context.asyncAssertSuccess(storedRequestResult -> { + storedRequestResultFuture.onComplete(context.asyncAssertSuccess(storedRequestResult -> { final Map expectedRequests = new HashMap<>(); expectedRequests.put("1", "value1"); expectedRequests.put("2", "value2"); @@ -410,7 +410,7 @@ public void getAmpStoredDataUnionSelectByIdShouldReturnStoredRequests(TestContex // then final Async async = context.async(); - storedRequestResultFuture.setHandler(context.asyncAssertSuccess(storedRequestResult -> { + storedRequestResultFuture.onComplete(context.asyncAssertSuccess(storedRequestResult -> { final Map expectedRequests = new HashMap<>(); expectedRequests.put("1", "value1"); expectedRequests.put("2", "value2"); @@ -429,7 +429,7 @@ public void getStoredDataShouldReturnResultWithErrorIfNoStoredRequestFound(TestC // then final Async async = context.async(); - storedRequestResultFuture.setHandler(context.asyncAssertSuccess(storedRequestResult -> { + storedRequestResultFuture.onComplete(context.asyncAssertSuccess(storedRequestResult -> { assertThat(storedRequestResult).isEqualTo(StoredDataResult.of(singletonMap("1", "value1"), emptyMap(), singletonList("No stored request found for id: 3"))); async.complete(); @@ -444,7 +444,7 @@ public void getStoredDataShouldReturnResultWithErrorIfNoStoredImpFound(TestConte // then final Async async = context.async(); - storedRequestResultFuture.setHandler(context.asyncAssertSuccess(storedRequestResult -> { + storedRequestResultFuture.onComplete(context.asyncAssertSuccess(storedRequestResult -> { assertThat(storedRequestResult).isEqualTo(StoredDataResult.of(emptyMap(), singletonMap("4", "value4"), singletonList("No stored imp found for id: 6"))); async.complete(); @@ -460,7 +460,7 @@ public void getAmpStoredDataShouldReturnResultWithErrorIfNoStoredRequestFound(Te // then final Async async = context.async(); - storedRequestResultFuture.setHandler(context.asyncAssertSuccess(storedRequestResult -> { + storedRequestResultFuture.onComplete(context.asyncAssertSuccess(storedRequestResult -> { assertThat(storedRequestResult).isEqualTo(StoredDataResult.of(singletonMap("1", "value1"), emptyMap(), singletonList("No stored request found for id: 3"))); async.complete(); @@ -485,7 +485,7 @@ public void getStoredDataShouldReturnErrorIfResultContainsLessColumnsThanExpecte // then final Async async = context.async(); - storedRequestResultFuture.setHandler(context.asyncAssertSuccess(storedRequestResult -> { + storedRequestResultFuture.onComplete(context.asyncAssertSuccess(storedRequestResult -> { assertThat(storedRequestResult).isEqualTo(StoredDataResult.of(emptyMap(), emptyMap(), singletonList("Error occurred while mapping stored request data"))); async.complete(); @@ -510,7 +510,7 @@ public void getAmpStoredDataShouldReturnErrorIfResultContainsLessColumnsThanExpe // then final Async async = context.async(); - storedRequestResultFuture.setHandler(context.asyncAssertSuccess(storedRequestResult -> { + storedRequestResultFuture.onComplete(context.asyncAssertSuccess(storedRequestResult -> { assertThat(storedRequestResult).isEqualTo(StoredDataResult.of(emptyMap(), emptyMap(), singletonList("Error occurred while mapping stored request data"))); async.complete(); @@ -526,7 +526,7 @@ public void getStoredDataShouldReturnErrorAndEmptyResult(TestContext context) { // then final Async async = context.async(); - storedRequestResultFuture.setHandler(context.asyncAssertSuccess(storedRequestResult -> { + storedRequestResultFuture.onComplete(context.asyncAssertSuccess(storedRequestResult -> { assertThat(storedRequestResult).isEqualTo(StoredDataResult.of(emptyMap(), emptyMap(), singletonList("No stored requests for ids [3, 4] and stored imps for ids [6, 7] were found"))); async.complete(); @@ -542,7 +542,7 @@ public void getAmpStoredDataShouldReturnErrorAndEmptyResult(TestContext context) // then final Async async = context.async(); - storedRequestResultFuture.setHandler(context.asyncAssertSuccess(storedRequestResult -> { + storedRequestResultFuture.onComplete(context.asyncAssertSuccess(storedRequestResult -> { assertThat(storedRequestResult).isEqualTo(StoredDataResult.of(emptyMap(), emptyMap(), singletonList("No stored requests for ids [3, 4] were found"))); async.complete(); @@ -557,7 +557,7 @@ public void getAmpStoredDataShouldIgnoreImpIdsArgument(TestContext context) { // then final Async async = context.async(); - storedRequestResultFuture.setHandler(context.asyncAssertSuccess(storedRequestResult -> { + storedRequestResultFuture.onComplete(context.asyncAssertSuccess(storedRequestResult -> { assertThat(storedRequestResult).isEqualTo(StoredDataResult.of(singletonMap("1", "value1"), emptyMap(), emptyList())); async.complete(); @@ -576,7 +576,7 @@ public void getStoredResponseShouldReturnExpectedResult(TestContext context) { expectedResponses.put("1", "response1"); expectedResponses.put("2", "response2"); - future.setHandler(context.asyncAssertSuccess(storedResponseDataResult -> { + future.onComplete(context.asyncAssertSuccess(storedResponseDataResult -> { assertThat(storedResponseDataResult) .isEqualTo(StoredResponseDataResult.of(expectedResponses, emptyList())); async.complete(); @@ -591,7 +591,7 @@ public void getStoredResponseShouldReturnResultWithErrorIfNotAllStoredResponsesW // then final Async async = context.async(); - storedResponseDataResultFuture.setHandler(context.asyncAssertSuccess(storedResponseDataResult -> { + storedResponseDataResultFuture.onComplete(context.asyncAssertSuccess(storedResponseDataResult -> { assertThat(storedResponseDataResult).isEqualTo(StoredResponseDataResult.of(singletonMap("1", "response1"), singletonList("No stored response found for id: 3"))); async.complete(); @@ -615,7 +615,7 @@ public void getStoredResponseShouldReturnErrorIfResultContainsLessColumnsThanExp // then final Async async = context.async(); - storedResponseDataResultFuture.setHandler(context.asyncAssertSuccess(storedResponseDataResult -> { + storedResponseDataResultFuture.onComplete(context.asyncAssertSuccess(storedResponseDataResult -> { assertThat(storedResponseDataResult).isEqualTo(StoredResponseDataResult.of(emptyMap(), singletonList("Result set column number is less than expected"))); async.complete(); @@ -630,7 +630,7 @@ public void getStoredResponseShouldReturnErrorAndEmptyResult(TestContext context // then final Async async = context.async(); - storedResponseDataResultFuture.setHandler(context.asyncAssertSuccess(storedResponseDataResult -> { + storedResponseDataResultFuture.onComplete(context.asyncAssertSuccess(storedResponseDataResult -> { assertThat(storedResponseDataResult).isEqualTo(StoredResponseDataResult.of(emptyMap(), singletonList("No stored responses were found for ids: 3,4"))); async.complete(); diff --git a/src/test/java/org/prebid/server/vertx/CircuitBreakerTest.java b/src/test/java/org/prebid/server/vertx/CircuitBreakerTest.java index 5402bf37c40..f7022d90ec1 100644 --- a/src/test/java/org/prebid/server/vertx/CircuitBreakerTest.java +++ b/src/test/java/org/prebid/server/vertx/CircuitBreakerTest.java @@ -148,7 +148,7 @@ private Future execute(TestContext context, Handler> han final Future future = circuitBreaker.execute(handler); final Async async = context.async(); - future.setHandler(ar -> async.complete()); + future.onComplete(ar -> async.complete()); async.await(); return future; diff --git a/src/test/java/org/prebid/server/vertx/http/BasicHttpClientTest.java b/src/test/java/org/prebid/server/vertx/http/BasicHttpClientTest.java index b78fdcd5302..50794c292ca 100644 --- a/src/test/java/org/prebid/server/vertx/http/BasicHttpClientTest.java +++ b/src/test/java/org/prebid/server/vertx/http/BasicHttpClientTest.java @@ -166,7 +166,7 @@ public void requestShouldFailIfHttpRequestTimedOut(TestContext context) { // when final Async async = context.async(); final Future future = httpClient.get("http://localhost:" + serverPort, 1000L); - future.setHandler(ar -> async.complete()); + future.onComplete(ar -> async.complete()); async.await(); // then @@ -188,7 +188,7 @@ public void requestShouldFailIfHttpResponseTimedOut(TestContext context) { // when final Async async = context.async(); final Future future = httpClient.get("http://localhost:" + serverPort, 1000L); - future.setHandler(ar -> async.complete()); + future.onComplete(ar -> async.complete()); async.await(); // then diff --git a/src/test/java/org/prebid/server/vertx/http/CircuitBreakerSecuredHttpClientTest.java b/src/test/java/org/prebid/server/vertx/http/CircuitBreakerSecuredHttpClientTest.java index f1ec54b59ec..138af53257f 100644 --- a/src/test/java/org/prebid/server/vertx/http/CircuitBreakerSecuredHttpClientTest.java +++ b/src/test/java/org/prebid/server/vertx/http/CircuitBreakerSecuredHttpClientTest.java @@ -264,7 +264,7 @@ private Future doRequest(TestContext context) { 0L); final Async async = context.async(); - future.setHandler(ar -> async.complete()); + future.onComplete(ar -> async.complete()); async.await(); return future; diff --git a/src/test/java/org/prebid/server/vertx/jdbc/CircuitBreakerSecuredJdbcClientTest.java b/src/test/java/org/prebid/server/vertx/jdbc/CircuitBreakerSecuredJdbcClientTest.java index 35cdf514f05..ea0e49fb1ce 100644 --- a/src/test/java/org/prebid/server/vertx/jdbc/CircuitBreakerSecuredJdbcClientTest.java +++ b/src/test/java/org/prebid/server/vertx/jdbc/CircuitBreakerSecuredJdbcClientTest.java @@ -78,7 +78,7 @@ public void executeQueryShouldReturnResultIfCircuitIsClosedAndQuerySucceeded(Tes resultSet -> resultSet.getResults().get(0).getString(0), timeout); // then - future.setHandler(context.asyncAssertSuccess(result -> + future.onComplete(context.asyncAssertSuccess(result -> assertThat(result).isEqualTo("value"))); } @@ -92,7 +92,7 @@ public void executeQueryShouldReturnExceptionIfCircuitIsClosedAndQueryFails(Test final Future future = jdbcClient.executeQuery("query", emptyList(), identity(), timeout); // then - future.setHandler(context.asyncAssertFailure(throwable -> + future.onComplete(context.asyncAssertFailure(throwable -> assertThat(throwable).isInstanceOf(RuntimeException.class).hasMessage("exception1"))); } @@ -107,7 +107,7 @@ public void executeQueryShouldNotExecuteQueryIfCircuitIsOpened(TestContext conte .recover(ignored -> jdbcClient.executeQuery("query", emptyList(), identity(), timeout)); // 2 call // then - future.setHandler(context.asyncAssertFailure(throwable -> { + future.onComplete(context.asyncAssertFailure(throwable -> { assertThat(throwable).isInstanceOf(RuntimeException.class).hasMessage("open circuit"); verify(wrappedJdbcClient) @@ -125,13 +125,13 @@ public void executeQueryShouldReturnExceptionIfCircuitIsHalfOpenedAndQueryFails( final Async async = context.async(); jdbcClient.executeQuery("query", emptyList(), identity(), timeout) // 1 call .recover(ignored -> jdbcClient.executeQuery("query", emptyList(), identity(), timeout)) // 2 call - .setHandler(ignored -> vertx.setTimer(201L, id -> async.complete())); + .onComplete(ignored -> vertx.setTimer(201L, id -> async.complete())); async.await(); final Future future = jdbcClient.executeQuery("query", emptyList(), identity(), timeout); // 3 call // then - future.setHandler(context.asyncAssertFailure(exception -> { + future.onComplete(context.asyncAssertFailure(exception -> { assertThat(exception).isInstanceOf(RuntimeException.class).hasMessage("exception1"); verify(wrappedJdbcClient, times(2)) @@ -150,14 +150,14 @@ public void executeQueryShouldReturnResultIfCircuitIsHalfOpenedAndQuerySucceeded final Async async = context.async(); jdbcClient.executeQuery("query", emptyList(), identity(), timeout) // 1 call .recover(ignored -> jdbcClient.executeQuery("query", emptyList(), identity(), timeout)) // 2 call - .setHandler(ignored -> vertx.setTimer(201L, id -> async.complete())); + .onComplete(ignored -> vertx.setTimer(201L, id -> async.complete())); async.await(); final Future future = jdbcClient.executeQuery("query", emptyList(), resultSet -> resultSet.getResults().get(0).getString(0), timeout); // 3 call // then - future.setHandler(context.asyncAssertSuccess(result -> { + future.onComplete(context.asyncAssertSuccess(result -> { assertThat(result).isEqualTo("value"); verify(wrappedJdbcClient, times(2)) @@ -177,16 +177,16 @@ public void executeQueryShouldFailsWithOriginalExceptionIfOpeningIntervalExceeds // when final Async async = context.async(); final Future future1 = jdbcClient.executeQuery("query", emptyList(), identity(), timeout) // 1 call - .setHandler(ignored -> vertx.setTimer(101L, id -> async.complete())); + .onComplete(ignored -> vertx.setTimer(101L, id -> async.complete())); async.await(); final Future future2 = jdbcClient.executeQuery("query", emptyList(), identity(), timeout); // 2 call // then - future1.setHandler(context.asyncAssertFailure(exception -> + future1.onComplete(context.asyncAssertFailure(exception -> assertThat(exception).isInstanceOf(RuntimeException.class).hasMessage("exception1"))); - future2.setHandler(context.asyncAssertFailure(exception -> + future2.onComplete(context.asyncAssertFailure(exception -> assertThat(exception).isInstanceOf(RuntimeException.class).hasMessage("exception2"))); verify(wrappedJdbcClient, times(2)) @@ -207,7 +207,7 @@ public void circuitBreakerGaugeShouldReportOpenedWhenCircuitOpen(TestContext con verify(metrics).createDatabaseCircuitBreakerGauge(gaugeValueProviderCaptor.capture()); final BooleanSupplier gaugeValueProvider = gaugeValueProviderCaptor.getValue(); - future.setHandler(context.asyncAssertFailure(throwable -> + future.onComplete(context.asyncAssertFailure(throwable -> assertThat(gaugeValueProvider.getAsBoolean()).isTrue())); } @@ -222,7 +222,7 @@ public void circuitBreakerGaugeShouldReportClosedWhenCircuitClosed(TestContext c final Async async = context.async(); jdbcClient.executeQuery("query", emptyList(), identity(), timeout) // 1 call .recover(ignored -> jdbcClient.executeQuery("query", emptyList(), identity(), timeout)) // 2 call - .setHandler(ignored -> vertx.setTimer(201L, id -> async.complete())); + .onComplete(ignored -> vertx.setTimer(201L, id -> async.complete())); async.await(); final Future future = jdbcClient.executeQuery("query", emptyList(), @@ -233,7 +233,7 @@ public void circuitBreakerGaugeShouldReportClosedWhenCircuitClosed(TestContext c verify(metrics).createDatabaseCircuitBreakerGauge(gaugeValueProviderCaptor.capture()); final BooleanSupplier gaugeValueProvider = gaugeValueProviderCaptor.getValue(); - future.setHandler(context.asyncAssertSuccess(throwable -> + future.onComplete(context.asyncAssertSuccess(throwable -> assertThat(gaugeValueProvider.getAsBoolean()).isFalse())); }