Vert.x 4.5.0 released!

178 views
Skip to first unread message

Julien Viet

unread,
Nov 16, 2023, 11:26:31 AM11/16/23
to vert.x
Hi everyone,

we have just released Eclipse Vert.x 4.5.0 which comes with a great
set of new features, including virtual thread support!

Here is the blog announcement https://vertx.io/blog/eclipse-vert-x-4-5-0/
and most importantly a recap of new important things you can find
https://vertx.io/blog/whats-new-in-vert-x-4-5/

Kudos to all contributors for the great work 🎉

Note : some features announced were already available in 4.4.x but not
properly announced, so we thought it was best to recap all the
important changes since the 4.4.0 announce.

Enjoy

Julien

Yeikel

unread,
Nov 20, 2023, 11:23:14 AM11/20/23
to vert.x
Thank you for the release, many exiting features!  

I just wanted to drop by to mention, that the following code : 

private <T> TestObserver<T> futureToTestObserver(Future<T> future) {
final TestObserver<T> testObserver = new TestObserver<>();
SingleHelper.toSingle(future::onComplete).subscribe(testObserver);
return testObserver;
}

No longer compiles with Vertx 4.5.0 due to : Reference to 'onComplete' is ambiguous, both 'onComplete(Handler<AsyncResult<T>>)' and 'onComplete(Handler<T>, Handler<Throwable>)' match

I believe that this was introduced with https://github.com/eclipse-vertx/vert.x/pull/4830, and it is a minor breaking change that I do not know if it was intentional  given that I could not find any reference to the release notes about the same

Thank you! 

Julien Viet

unread,
Nov 20, 2023, 4:31:38 PM11/20/23
to ve...@googlegroups.com
Hi,

can you the toSingle method signature with which it creates an issue ?

Julien
> --
> You received this message because you are subscribed to the Google Groups "vert.x" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to vertx+un...@googlegroups.com.
> To view this discussion on the web, visit https://groups.google.com/d/msgid/vertx/a6b25e08-f27b-471c-8920-bec050e3c7b4n%40googlegroups.com.

Yeikel

unread,
Nov 20, 2023, 4:55:38 PM11/20/23
to vert.x
Hi, 

Your message was cut-off but If you meant to ask what's the signature of the toSingle method, here it is : 

package io.vertx.reactivex;

// imports omitted for brevity 
public class SingleHelper {

/**
* Returns a {@link Single} that, when subscribed, uses the provided {@code handler} to adapt a callback-based asynchronous method.
* <p>
* For example:
* <pre> {@code
* io.vertx.core.Vertx vertx = Vertx.vertx();
* Single<String> deploymentId = SingleHelper.toSingle(handler -> vertx.deployVerticle("org.acme.MyVerticle", handler));
* }</pre>
* <p>
* This is useful when using RxJava without the Vert.x Rxified API or your own asynchronous methods.
* <p>
* The asynchronous method result <strong>must not</strong> be {@code null}, as an RxJava 2 {@link Single} does not allow {@code null} values.
*
* @param handler the code executed when the returned {@link Single} is subscribed
*/
public static <T> Single<T> toSingle(Consumer<Handler<AsyncResult<T>>> handler) {
return AsyncResultSingle.toSingle(handler);
}

ariffi...@gmail.com

unread,
Nov 21, 2023, 5:51:33 PM11/21/23
to vert.x
Hi Julien,

I appreciate the constant improvements to new versions.

I am upgrading to 4.5.0.... I changed the DeploymentOptions to reflect the new way to specify a worker verticle:

// Deploy Cassandra verticle as a worker verticle
DeploymentOptions dbOptions = new DeploymentOptions().setThreadingModel(ThreadingModel.WORKER).setInstances(verticleInstanceCounts * 4).setHa(true);
vertx.deployVerticle(verticleFactory.prefix() + ":" + BeaconDbApiVerticle.class.getName(), dbOptions, results -> {
if (results.succeeded()) {
LOGGER.info("Cassandra DB Deployment id is: " + results.result());
} else {
LOGGER.error("Cassandra DB Deployment failed! " + results + " Cause :" + results.cause().toString());
System.exit(1);
}
});


But I am getting a deprecated warning below:

=======================================================

ariffin@Ariffins-iMac-2020 beaconApi % java -version

openjdk version "17.0.9" 2023-10-17 LTS

OpenJDK Runtime Environment Corretto-17.0.9.8.1 (build 17.0.9+8-LTS)

OpenJDK 64-Bit Server VM Corretto-17.0.9.8.1 (build 17.0.9+8-LTS, mixed mode, sharing)

ariffin@Ariffins-iMac-2020 beaconApi % ./gradlew clean build 

Starting a Gradle Daemon (subsequent builds will be faster)


> Task :compileJava

/Volumes/Ariffin EXT/Dev/git/beaconApi/src/main/java/com/analytics/BeaconApiApplication.java:102: warning: [deprecation] setThreadingModel(ThreadingModel) in DeploymentOptions has been deprecated

        DeploymentOptions dbOptions = new DeploymentOptions().setThreadingModel(ThreadingModel.WORKER).setInstances(verticleInstanceCounts * 4).setHa(true);

                                                             ^

1 warning


BUILD SUCCESSFUL in 9s

6 actionable tasks: 6 executed

=======================================================

Can you tell me what I am doing wrong?

Thank you.

-a

ariffi...@gmail.com

unread,
Nov 23, 2023, 3:09:39 AM11/23/23
to vert.x
Bump.

-a

Julien Viet

unread,
Dec 5, 2023, 12:57:38 PM12/5/23
to ve...@googlegroups.com
Hi,

that is a mistake that only appears in Java 11

if you compile with Java 8 that will not happen.

it will be fixed in 4.5.1

thanks for bringing this valuable issue to my eyes.

Julien
> --
> You received this message because you are subscribed to the Google Groups "vert.x" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to vertx+un...@googlegroups.com.
> To view this discussion on the web, visit https://groups.google.com/d/msgid/vertx/f4cb90c7-147a-406d-908d-164aa32d75f2n%40googlegroups.com.

Yeikel

unread,
Dec 5, 2023, 2:21:21 PM12/5/23
to vert.x
How you'd refactor the following snippet after the changes to the Future class? 

The alternatives I am thinking about seem overly complicated
return SingleHelper.toSingle(resultFuture::onComplete).toObservable().onErrorResumeNext(err -> {
if (err instanceof DocumentNotFoundException) {
return Observable.empty();
} else {
return Observable.error(err);
}
});

Julien Viet

unread,
Dec 6, 2023, 3:49:53 AM12/6/23
to ve...@googlegroups.com
Hi,

you should get rid of single and use await on resultFuture

try {
return Collections.singletonList(await(resultFuture));
} catch (DocumentNotFoundException) {
return Collections.emptyList();
> To view this discussion on the web, visit https://groups.google.com/d/msgid/vertx/37f29ce8-9cb8-4393-8a6a-9cff6325b650n%40googlegroups.com.

Yeikel

unread,
Dec 6, 2023, 7:19:30 AM12/6/23
to ve...@googlegroups.com
Thank you for the suggestion but in this case it is a library and that would mean cha ging the return type and a larger refactoring excercise

Also, from what I understand, I'd need Java 21 to use await, no? We're still using Java 17 and migrating will take some time and effort


Julien Viet

unread,
Dec 6, 2023, 11:08:29 AM12/6/23
to ve...@googlegroups.com
I see.

await is actually very new in the Java landscape and we don't expect
an adoption before a few years.
> To view this discussion on the web, visit https://groups.google.com/d/msgid/vertx/CAMMhyA3hhqGL3aBAPvxG4jaMVRKcSF1fFa5rZiJGuDRnQLdELA%40mail.gmail.com.

Yeikel

unread,
Dec 6, 2023, 7:59:29 PM12/6/23
to vert.x
Yeah, that's understandable

How do you suggest I refactor the code I mentioned? The earlier code was "clean" and now it seems that after the Future class changes, I need to do some overly complicated alternative. Maybe I am overthinking it? 

Thanks! 

Reply all
Reply to author
Forward
0 new messages