migrate deprecated/removed Future calls in preparation for vert.x4 migration
Description
Environment
Potential Workaround
relates to
Checklist
hideTestRail: Results
Activity
Julian LadischMay 6, 2020 at 5:45 PM
@Oleksii Kuzminov 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 AMEdited
@Oleksii Kuzminov 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 3.4.x support ended March 2017: https://github.com/eclipse-vertx/vert.x/releases?after=3.4.2
Vert.x 3.5.x support ended October 2018: https://github.com/eclipse-vertx/vert.x/releases?after=3.7.0
Vert.x 3.6.x support ended January 2019: https://github.com/eclipse-vertx/vert.x/releases?after=3.8.2
Vert.x 3.7.x support ended May 2019: https://github.com/eclipse-vertx/vert.x/releases?after=3.8.4
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
@Oleksii Kuzminov 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 AMEdited
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:
Promise<String> promise = Promise.promise();
vertx.setTimer(1000, id -> promise.complete("hello");
return promise.future();
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).