-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
requests to io.vertx.core.http.impl.Http1xServerRequest.trace() are throwing NullPointerException #4016
Comments
does it always happen |
what used to be your vertx version before 4.1.1 ? |
can you provide a full reproducer ? |
this is always related with an error that we have in the web sockets |
we were using 3.9.4 |
In the afternoon we're going to give it another look to get more information and see if it's possible to create a producer |
Hi @vietj , Could not create a producer, but will try to explain what happens the best I can: We have a SPA with a simple backend in java+vert.x
private void registerFailureHandler(Route route) {
route.failureHandler(ctx -> DefaultHttpPresenter
.create(ctx, requestContextFactory.create(ctx))
.onError(ctx.failure(), FROM_VERTX_FAILURE_HANDLER));
}
HttpServerRequest request = routingContext.request();
HttpServerResponse response = routingContext.response();
if (request.path().contains("/api/2/notifications/eventbus/") && throwable == null) {
LOG.debug("response.closed: " + response.closed()); //false - TCP connection is still open
LOG.debug("response.ended: " + response.ended()); //false - response was not yet written
LOG.debug("request.isEnded: " + request.isEnded()); //true - request was already read
//return;
}
HttpServerResponse response = routingContext.response();
response
.setStatusCode(INTERNAL_SERVER_ERROR.code())
.putHeader(X_SHOULD_LOG_AS_WARNING, Boolean.TRUE.toString())
.end(); //response.end() will be invoked and NPE will be thrown
|
thanks @amrsantos |
ok I see what is incorrect here then. thanks |
there is definitely something we can do to avoid the NPE, however you should not try to end the response here since the HTTP response is already ended after the WebSocket handshake. I will update the implementation so that you get another error when ending the response such as an IllegalStateException that signals the response is already ended. |
i.e response.ended() should print true here and it prints false |
@vietj Thanks a lot |
Version
Vert.x 4.1.1
Context
After upgrading to Vert.x 4.1.1 we started experiencing these errors on our logs
java.lang.NullPointerException: Cannot invoke "io.vertx.core.http.impl.Http1xServerRequest.trace()" because "request" is null
at io.vertx.core.http.impl.Http1xServerConnection.reportResponseComplete(Http1xServerConnection.java:277) ~[vertx-core-4.1.1.jar:4.1.1]
at io.vertx.core.http.impl.Http1xServerConnection.responseComplete(Http1xServerConnection.java:211) ~[vertx-core-4.1.1.jar:4.1.1]
at io.vertx.core.http.impl.Http1xServerResponse.end(Http1xServerResponse.java:409) ~[vertx-core-4.1.1.jar:4.1.1]
at io.vertx.core.http.impl.Http1xServerResponse.end(Http1xServerResponse.java:388) ~[vertx-core-4.1.1.jar:4.1.1]
at io.vertx.core.http.impl.Http1xServerResponse.end(Http1xServerResponse.java:444) ~[vertx-core-4.1.1.jar:4.1.1]
at io.vertx.reactivex.core.http.HttpServerResponse.end(HttpServerResponse.java:156) ~[vertx-rx-java2-4.1.1.jar:4.1.1]
at io.vertx.reactivex.core.http.HttpServerResponse.end(HttpServerResponse.java:163) ~[vertx-rx-java2-4.1.1.jar:4.1.1]
something similar to #3897 but on the trace() call
Do you have a reproducer?
We found out that this snippet throws the exception:
but this one doesn't
thanks in advance
The text was updated successfully, but these errors were encountered: