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
Metric - Http1xServerConnection request is null #4546
Comments
@glassfox Does this happen all the time of for each and every request? |
hi @tsegismont Following example of route: router.route().handler(ctx -> {
ctx.addHeadersEndHandler(c -> {
...
ctx.fail(555);
...
});
ctx.next();
}); Let me know if you agree to close this bug. |
Please do not close yet. If you can add a little more details to the snippet, perhaps we can create a test and change our code to fail nicely instead of failing with a NPE. |
Sure. I will create Unitest. |
Thank you
|
import java.util.concurrent.atomic.AtomicBoolean;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import io.vertx.core.AbstractVerticle;
import io.vertx.core.Future;
import io.vertx.core.Promise;
import io.vertx.core.Vertx;
import io.vertx.core.VertxOptions;
import io.vertx.core.http.RequestOptions;
import io.vertx.core.metrics.MetricsOptions;
import io.vertx.ext.web.Router;
import io.vertx.junit5.VertxExtension;
import io.vertx.junit5.VertxTestContext;
@ExtendWith(VertxExtension.class)
public class AppImplTest {
@BeforeEach
protected void setUp(Vertx vertx) throws Exception {
}
@Test
void test(Vertx vertx, VertxTestContext testCtx) {
AtomicBoolean flag = new AtomicBoolean();
VertxOptions vertxOptions = new VertxOptions().setMetricsOptions(new MetricsOptions().setEnabled(true));
Future.succeededFuture().map(Vertx.vertx(vertxOptions))
.compose(myVertx ->
myVertx.deployVerticle(new AbstractVerticle() {
@Override
public void start(Promise<Void> startPromise) throws Exception {
var router = Router.router(this.vertx);
router.route().handler(ctx -> {
ctx.addHeadersEndHandler(c-> {
if(!flag.compareAndExchange(false, true)) {
ctx.fail(555);
}
});
ctx.end();
});
router.route().failureHandler(ctx -> {
if(null != ctx.failure()) {
testCtx.failNow(ctx.failure());
}
ctx.next();
});
this.vertx.createHttpServer()
.requestHandler(router)
.listen()
.<Void>mapEmpty()
.onComplete(startPromise);
}
}))
.compose(nil ->
vertx.createHttpClient()
.request(new RequestOptions())
.compose(req -> req.send())
)
.onComplete(testCtx.succeedingThenComplete());
}
} |
See eclipse-vertx#4546 This aligns behaviors of Http 1 and Http2 servers. Signed-off-by: Thomas Segismont <tsegismont@gmail.com>
See #4546 This aligns behaviors of Http 1 and Http2 servers. Signed-off-by: Thomas Segismont <tsegismont@gmail.com> Signed-off-by: Thomas Segismont <tsegismont@gmail.com>
…ipse-vertx#4549) Fixes eclipse-vertx#4546 This aligns behaviors of Http 1 and Http2 servers. Signed-off-by: Thomas Segismont <tsegismont@gmail.com>
Below exception occurred for enabled metric:
Occurred on vertx version: 4.3.4 and 4.3.5
The text was updated successfully, but these errors were encountered: