client_java
client_java copied to clipboard
Default metrics handler throws exception on Vert.x 4.0.2
val vertxVersion = "4.0.2"
val promVersion = "0.10.0"
dependencies {
implementation("io.vertx:vertx-core:$vertxVersion")
implementation("io.vertx:vertx-web:$vertxVersion")
implementation("io.prometheus:simpleclient_vertx:$promVersion")
}
public static void main(String[] args) {
final var vertx = Vertx.vertx();
final var router = Router.router(vertx);
router.get("/metrics").handler(new MetricsHandler());
router.errorHandler(500, e -> {
if (e.failed()) {
e.failure().printStackTrace();
e.response().end(e.failure().getMessage());
}
});
vertx.createHttpServer().requestHandler(router).listen(8080);
}
# result of calling GET localhost:8080/metrics:
java.lang.NoSuchMethodError: io.vertx.core.http.HttpServerResponse.end(Lio/vertx/core/buffer/Buffer;)V
...
Thanks for reporting. I can reproduce this.
The reason is that the method signature changed. simpleclient_vertx
was developed with Vert.x 3.3.2, and there HttpServerResponse.end(Buffer)
returns void
:
https://github.com/eclipse-vertx/vert.x/blob/3.3.2/src/main/java/io/vertx/core/http/HttpServerResponse.java#L244
In Vert.x 4.0.2, the same method returns Future<Void>
.
https://github.com/eclipse-vertx/vert.x/blob/4.0.2/src/main/java/io/vertx/core/http/HttpServerResponse.java#L277
I'm not sure at the moment whether we can fix this and provide a simpleclient_vertx
that works with both Vert.x versions, or whether we need separate simpleclient_vertx
versions for Vert.x 3 and Vert.x 4.
@fstab Following up for the fix. Are you guys planning to fix this issue or do we need to find an alternative to solve this because we can not use Vert.x.3 version and we have to use Vert.x.4.
Do you guys have any alternative solution?
See also #731.