migrate deprecated/removed Future calls in preparation for vert.x4 migration

Description

In newer RMB release the Vert.x version has been incremented. Since Vert.x update some Future methods became deprecated.
In data-import modules most business-logic is written in composed manner using Future methods. The code is tightly coupled with Future class, that obviously requires a huge rework of existing code base.

These Future methods haven been deprecated and will be removed in Vertx 4.

Quote from https://github.com/vert-x3/wiki/wiki/3.8.0-Deprecations-and-breaking-changes#future-creation-and-completion :

// Deprecated Future<String> fut = Future.future(); vertx.setTimer(1000, id -> fut.complete("hello"); return fut; // Now you should do this Promise<String> promise = Promise.promise(); vertx.setTimer(1000, id -> promise.complete("hello"); return promise.future();

Creating and completing futures is deprecated in Vert.x 3.8 in favor of promises.

Quote from https://github.com/vert-x3/wiki/wiki/4.0.0-Deprecations-and-breaking-changes#%EF%B8%8F-future-sethandler-method-pruning :

☑️ Future setHandler method pruning

https://github.com/eclipse-vertx/vert.x/issues/3329

Vert.x supports multiple handler per future in 4.0. The setHandler method does convey the meaning that a single handler per future can be set and unset and the onComplete, onSuccess, onFailure methods shall be used instead.

The setHandler method usage must be replaced by the onComplete method, e.g

// Before Future<String> fut = getSomeFuture(); fut.setHandler(ar -> ...); // After Future<String> fut = getSomeFuture(); fut.onComplete(ar -> ...);

Vert.x 3.9 deprecates setHandler.

☑️ Future completer method pruning

https://github.com/eclipse-vertx/vert.x/issues/2869

The Future#completer() method is deprecated since Future<T> extends Handler<AsyncResult<T>> for some time now (and the default implementation actually returns this).

Environment

None

Potential Workaround

None

Checklist

hide

TestRail: Results

Activity

Show:

Julian LadischMay 6, 2020 at 5:45 PM

Can you post a link to an example Java file where migrating from Future to Promise requires huge rework?

Julian LadischApril 21, 2020 at 8:39 AM
Edited

Can you post a link to an example Java file where migrating from Future to Promise requires huge rework?

Julian LadischDecember 13, 2019 at 11:42 AM

The reason to update Vert.x is that old Vert.x versions are no longer supported - no security fixes, no bug fixes.

Vert.x 4.0.x is expected to get released by the end of 2019. At some time Vert.x 3.8.x support will end.

Julian LadischDecember 13, 2019 at 11:14 AM

Can you post a link to an example Java file where migrating from Future to Promise requires huge rework?

Julian LadischDecember 13, 2019 at 11:12 AM
Edited

The Future class has NOT been deprecated.
Only some Future methods haven been deprecated:

  • Future creation: Future.future()

  • Future completion: Future.complete(), Future.fail()

References:

Futures must still be used, most notably for Async Coordination:

The Promise has a method to return a Future:

  • promise.future()

The deprecation note contains an Promise example that returns a Future:

https://github.com/vert-x3/wiki/wiki/3.8.0-Deprecations-and-breaking-changes#future-creation-and-completion

Promise<String> promise = Promise.promise(); vertx.setTimer(1000, id -> promise.complete("hello"); return promise.future();
Done

Details

Assignee

Reporter

Priority

Story Points

Sprint

Development Team

Core: Platform

Fix versions

TestRail: Cases

Open TestRail: Cases

TestRail: Runs

Open TestRail: Runs

Created October 23, 2019 at 9:58 AM
Updated March 15, 2021 at 12:39 PM
Resolved May 4, 2020 at 8:33 AM
TestRail: Cases
TestRail: Runs

Flag notifications