Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update deprecated Vert.x setHandler with onComplete #1620

Merged
merged 1 commit into from
Dec 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public <T> void processEvent(T event) {

public <T> void processEvent(T event, TcfContext tcfContext) {
privacyEnforcementService.resultForVendorIds(reporterVendorIds, tcfContext)
.setHandler(privacyEnforcementMap -> delegateEvent(event, tcfContext, privacyEnforcementMap));
.onComplete(privacyEnforcementMap -> delegateEvent(event, tcfContext, privacyEnforcementMap));
}

private <T> void delegateEvent(T event,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ private void sendEvents(AtomicReference<Queue<String>> events) {
resetReportEventsConditions();

httpClient.request(HttpMethod.POST, url, headers, toGzippedBytes(copyToSend), timeoutMs)
.setHandler(this::handleReportResponse);
.onComplete(this::handleReportResponse);
}

private void resetReportEventsConditions() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ private Future<List<CategoryBidContext>> makeBidderToBidCategory(List<BidderResp
bidderResponse, primaryAdServer, publisher, timeout, withCategory, translateCategories))
.collect(Collectors.toList()));

compositeFuture.setHandler(ignored ->
compositeFuture.onComplete(ignored ->
collectCategoryFetchResults(compositeFuture, categoryBidContextsPromise, rejectedBids));

return categoryBidContextsPromise.future();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/prebid/server/deals/DealsProcessor.java
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ public Future<AuctionContext> 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<Tuple3<DeviceInfo, GeoInfo, UserDetails>> 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<DeviceInfo, GeoInfo, UserDetails> tuple) ->
enrichAuctionContext(context, tuple.getLeft(), tuple.getMiddle(), tuple.getRight()))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.<Void>promise().future())
.setHandler(result -> handleDeliveryResult(result, batchesCount, sentBatches));
.onComplete(result -> handleDeliveryResult(result, batchesCount, sentBatches));
}

protected Future<Void> sendBatch(DeliveryProgressReportBatch deliveryProgressReportBatch, ZonedDateTime now) {
Expand All @@ -136,7 +136,7 @@ protected Future<Void> sendBatch(DeliveryProgressReportBatch deliveryProgressRep
? setInterval(reportIntervalMs)
: Future.succeededFuture()),
(a, b) -> Promise.<Void>promise().future())
.setHandler(result -> handleBatchDelivery(result, deliveryProgressReportBatch, sentReports, promise));
.onComplete(result -> handleBatchDelivery(result, deliveryProgressReportBatch, sentReports, promise));
return promise.future();
}

Expand All @@ -160,12 +160,12 @@ protected Future<Void> 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));
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/prebid/server/deals/PlannerService.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<List<LineItemMetaData>> startRecoveryProcess(String planEndpoint, MultiMap headers) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/prebid/server/deals/RegisterService.java
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/prebid/server/deals/UserService.java
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public void advancePlans(ZonedDateTime now) {

public void initiateLineItemsFetching(ZonedDateTime now) {
fetchLineItemMetaData(planEndpoint, headers(now))
.setHandler(this::handleInitializationResult);
.onComplete(this::handleInitializationResult);
}

/**
Expand Down
26 changes: 13 additions & 13 deletions src/main/java/org/prebid/server/execution/RemoteFileSyncer.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<Boolean> downloadIfNotExist(RemoteFileProcessor fileProcessor) {
final Promise<Boolean> promise = Promise.promise();
checkFileExist(saveFilePath).setHandler(existResult ->
checkFileExist(saveFilePath).onComplete(existResult ->
handleFileExistingWithSync(existResult, fileProcessor, promise));
return promise.future();
}
Expand All @@ -124,9 +124,9 @@ private void handleFileExistingWithSync(AsyncResult<Boolean> 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());
Expand All @@ -136,7 +136,7 @@ private void handleFileExistingWithSync(AsyncResult<Boolean> existResult, Remote
private void handleServiceRespond(AsyncResult<?> processResult, Promise<Boolean> 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);
Expand All @@ -146,7 +146,7 @@ private void handleServiceRespond(AsyncResult<?> processResult, Promise<Boolean>

private Future<Void> cleanUp(String filePath) {
final Promise<Void> promise = Promise.promise();
checkFileExist(filePath).setHandler(existResult -> handleFileExistsWithDelete(filePath, existResult, promise));
checkFileExist(filePath).onComplete(existResult -> handleFileExistsWithDelete(filePath, existResult, promise));
return promise.future();
}

Expand All @@ -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);
}
}

Expand All @@ -185,15 +185,15 @@ private Future<Boolean> syncRemoteFiles() {

private Future<Void> tryDownload() {
final Promise<Void> promise = Promise.promise();
cleanUp(tmpFilePath).setHandler(event -> handleTmpDelete(event, promise));
cleanUp(tmpFilePath).onComplete(event -> handleTmpDelete(event, promise));
return promise.future();
}

private void handleTmpDelete(AsyncResult<Void> tmpDeleteResult, Promise<Void> promise) {
if (tmpDeleteResult.failed()) {
promise.fail(tmpDeleteResult.cause());
} else {
download().setHandler(downloadResult -> handleDownload(downloadResult, promise));
download().onComplete(downloadResult -> handleDownload(downloadResult, promise));
}
}

Expand Down Expand Up @@ -265,9 +265,9 @@ private void handleRetry(Promise<Void> 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))));
}
}
Expand Down Expand Up @@ -295,7 +295,7 @@ private void handleSync(RemoteFileProcessor remoteFileProcessor, AsyncResult<Boo
if (syncResult.result()) {
logger.info("Sync service for {0}", saveFilePath);
remoteFileProcessor.setDataPath(saveFilePath)
.setHandler(this::logFileProcessStatus);
.onComplete(this::logFileProcessStatus);
} else {
logger.info("Sync is not required for {0}", saveFilePath);
}
Expand All @@ -319,7 +319,7 @@ private void logFileProcessStatus(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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public CircuitBreakerSecuredGeoLocationService(Vertx vertx,

@Override
public Future<GeoInfo> 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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ public void handle(RoutingContext routingContext) {
metrics.updateCookieSyncRequestMetric();

toCookieSyncContext(routingContext)
.setHandler(cookieSyncContextResult -> handleCookieSyncContextResult(cookieSyncContextResult,
.onComplete(cookieSyncContextResult -> handleCookieSyncContextResult(cookieSyncContextResult,
routingContext));
}

Expand Down Expand Up @@ -218,7 +218,7 @@ private void handleCookieSyncContextResult(AsyncResult<CookieSyncContext> cookie
}

isAllowedForHostVendorId(tcfContext)
.setHandler(hostTcfResponseResult -> respondByTcfResponse(
.onComplete(hostTcfResponseResult -> respondByTcfResponse(
hostTcfResponseResult,
biddersToSync(cookieSyncContext),
cookieSyncContext));
Expand Down Expand Up @@ -365,7 +365,7 @@ private void respondByTcfResponse(AsyncResult<HostVendorTcfResponse> 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/prebid/server/handler/OptoutHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<RecaptchaResponse> result) {
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/prebid/server/handler/SetuidHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<SetuidContext> toSetuidContext(RoutingContext routingContext) {
Expand Down Expand Up @@ -152,7 +152,7 @@ private void handleSetuidContextResult(AsyncResult<SetuidContext> setuidContextR
}

isAllowedForHostVendorId(tcfContext)
.setHandler(hostTcfResponseResult -> respondByTcfResponse(hostTcfResponseResult, setuidContext));
.onComplete(hostTcfResponseResult -> respondByTcfResponse(hostTcfResponseResult, setuidContext));
} else {
final Throwable error = setuidContextResult.cause();
handleErrors(error, routingContext, null);
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/prebid/server/handler/VtrackHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}

Expand Down Expand Up @@ -176,7 +176,7 @@ private void handleAccountResult(AsyncResult<Account> asyncAccount,
final Boolean isEventEnabled = accountEventsEnabled(asyncAccount.result());
final Set<String> allowedBidders = biddersAllowingVastUpdate(vtrackPuts);
cacheService.cachePutObjects(vtrackPuts, isEventEnabled, allowedBidders, accountId, integration, timeout)
.setHandler(asyncCache -> handleCacheResult(asyncCache, routingContext));
.onComplete(asyncCache -> handleCacheResult(asyncCache, routingContext));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 <T, R> R addToEvent(T field, Consumer<T> consumer, R result) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 <T, R> R addToEvent(T field, Consumer<T> consumer, R result) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public String name() {
void updateStatus() {
final Promise<SQLConnection> 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())));
Expand Down
Loading