Skip to content
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

Response head already sent Exception #19621

Closed
MM87037 opened this issue Aug 24, 2021 · 1 comment · Fixed by #19708
Closed

Response head already sent Exception #19621

MM87037 opened this issue Aug 24, 2021 · 1 comment · Fixed by #19708
Assignees
Labels
Milestone

Comments

@MM87037
Copy link

MM87037 commented Aug 24, 2021

Describe the bug

When using lazy JWT authentication with http permissions observing below exceptions if JWT token in the request is expired.

[io.ver.ext.web.RoutingContext] (vert.x-eventloop-thread-22) Unhandled exception in router: java.lang.IllegalStateException: Response head already sent
or
[io.ver.ext.web.RoutingContext] (vert.x-eventloop-thread-0) Unhandled exception in router: java.lang.IllegalStateException: Response has already been written

Quarkus Extensions used: cdi, security, smallrye-context-propagation, smallrye-jwt, smallrye-openapi, swagger-ui, vertx, vertx-web

Config used:

quarkus.http.auth.proactive=false
quarkus.http.auth.permission.permit.paths=/q/*,/api/hello
quarkus.http.auth.permission.permit.policy=permit
quarkus.http.auth.permission.loggedin.paths=/api/*
quarkus.http.auth.permission.loggedin.policy=authenticated

Expected behavior

No Runtime exceptions

Actual behavior

Observing below exception

2021-08-24 17:00:00,950 ERROR [io.ver.ext.web.RoutingContext] (vert.x-eventloop-thread-22) Unhandled exception in router: java.lang.IllegalStateException: Response head already sent
	at io.vertx.core.http.impl.Http1xServerResponse.checkHeadWritten(Http1xServerResponse.java:675)
	at io.vertx.core.http.impl.Http1xServerResponse.setStatusCode(Http1xServerResponse.java:144)
	at io.quarkus.vertx.http.runtime.QuarkusErrorHandler.handle(QuarkusErrorHandler.java:77)
	at io.quarkus.vertx.http.runtime.QuarkusErrorHandler.handle(QuarkusErrorHandler.java:24)
	at io.vertx.ext.web.impl.RouteState.handleFailure(RouteState.java:1133)
	at io.vertx.ext.web.impl.RoutingContextImplBase.iterateNext(RoutingContextImplBase.java:148)
	at io.vertx.ext.web.impl.RoutingContextImpl.next(RoutingContextImpl.java:133)
	at io.vertx.ext.web.impl.RoutingContextImpl.doFail(RoutingContextImpl.java:591)
	at io.vertx.ext.web.impl.RoutingContextImpl.fail(RoutingContextImpl.java:184)
	at io.vertx.ext.web.impl.RoutingContextImpl.fail(RoutingContextImpl.java:173)
	at io.quarkus.vertx.http.runtime.security.HttpAuthorizer$3.accept(HttpAuthorizer.java:140)
	at io.quarkus.vertx.http.runtime.security.HttpAuthorizer$3.accept(HttpAuthorizer.java:137)

Observed below exception as well though not able to reproduce it always

2021-08-24 14:02:19,090 ERROR [io.ver.ext.web.RoutingContext] (vert.x-eventloop-thread-0) Unhandled exception in router: java.lang.IllegalStateException: Response has already been written
	at io.vertx.core.http.impl.Http1xServerResponse.checkValid(Http1xServerResponse.java:669)
	at io.vertx.core.http.impl.Http1xServerResponse.endHandler(Http1xServerResponse.java:310)
	at io.vertx.ext.web.impl.RoutingContextImpl.getEndHandlers(RoutingContextImpl.java:573)
	at io.vertx.ext.web.impl.RoutingContextImpl.addEndHandler(RoutingContextImpl.java:436)
	at io.quarkus.vertx.web.runtime.RouteHandler.handle(RouteHandler.java:90)
	at io.quarkus.vertx.web.runtime.RouteHandler.handle(RouteHandler.java:22)
	at io.vertx.ext.web.impl.RouteState.handleFailure(RouteState.java:1133)
	at io.vertx.ext.web.impl.RoutingContextImplBase.iterateNext(RoutingContextImplBase.java:148)
	at io.vertx.ext.web.impl.RoutingContextImpl.next(RoutingContextImpl.java:133)
	at io.vertx.ext.web.impl.RoutingContextImpl.doFail(RoutingContextImpl.java:591)
	at io.vertx.ext.web.impl.RoutingContextImpl.fail(RoutingContextImpl.java:184)
	at io.vertx.ext.web.impl.RoutingContextImpl.fail(RoutingContextImpl.java:173)
	at io.quarkus.vertx.http.runtime.security.HttpAuthorizer$3.accept(HttpAuthorizer.java:140)
	at io.quarkus.vertx.http.runtime.security.HttpAuthorizer$3.accept(HttpAuthorizer.java:137)

How to Reproduce?

https://github.com/MM87037/routing-error

Start the service and run below command

curl "http://localhost:8080/api/user" -H 'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJpc3MiOiJUZXN0Iiwic3ViIjoidW5tVW93TlBRNVEzdVh4WDNPRVkwTnRTRnNOWFZ6SlZnYVZyNm40MWNYbyIsInByZWZlcnJlZF91c2VybmFtZSI6IlRlc3RVc2VyQGNvbXBhbnkuY29tIiwiYXVkIjoiZjkzZWUxYTgtYmExYS00NDk0LWJmZTEtNjQzODIzMDIyNWVhIiwiaWF0IjoxNjI5NzMzMzE1LCJleHAiOjE2Mjk3MzY5MTUsIm5hbWUiOiJUZXN0IFVzZXIiLCJyb2xlcyI6WyJ3cml0ZSIsInJlYWQiLCJyZWxlYXNlIl0sImp0aSI6ImUzMGMxNWZjLTA0YzEtNDM0Yi1iZTZjLTU0N2E3Zjk4MjI0MiJ9.f52Q1JrH4JjeDbwn4NthuBYursCjeRrgd4uvCx0wGpilxaOVm7nvHlFkTKbiRofpEl8kE4YEangEGpiXPfn33Q5fZ_C2TjgQyrbNu9-IbSeDStLxIbhawW-NjyTI3EQY0zUrN9aOHvOWDitNTUVjBxHCIf1WTmyL15X6XT1qBczpTZKr-kkFs2L0Gxereu_gNxWgUPcyfC0vTOhjt3prZcpksv2W26gpKdTdJBmXm0xeOlkdxeIao_2kiJWTxJ22aUSLCESodNex-QV-40EjUz7B4YHSfEJ16mUjgLAOcpIwjjjZAvdHV92oa6alIgbbb35VjeqlPmKc29gQJNQP1Q'

or
Run maven build

mvn clean verify

Output of uname -a or ver

Windows 10 Git Bash or Linux ids-slpdf-service-117-qd7hx 3.10.0-1160.36.2.el7.x86_64 #1 SMP Thu Jul 8 02:53:40 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

Output of java -version

openjdk version "11.0.12" 2021-07-20

GraalVM version (if different from Java)

No response

Quarkus version or git rev

2.0 and above

Build tool (ie. output of mvnw --version or gradlew --version)

maven 3.8.1

Additional information

No response

@MM87037 MM87037 added the kind/bug Something isn't working label Aug 24, 2021
@quarkus-bot quarkus-bot bot added env/windows Impacts Windows machines triage/needs-triage labels Aug 24, 2021
@quarkus-bot
Copy link

quarkus-bot bot commented Aug 24, 2021

/cc @sberyozkin

@geoand geoand self-assigned this Aug 26, 2021
@geoand geoand removed the env/windows Impacts Windows machines label Aug 26, 2021
geoand added a commit to geoand/quarkus that referenced this issue Aug 26, 2021
stuartwdouglas added a commit to stuartwdouglas/quarkus that referenced this issue Aug 27, 2021
stuartwdouglas added a commit to stuartwdouglas/quarkus that referenced this issue Aug 27, 2021
stuartwdouglas added a commit to stuartwdouglas/quarkus that referenced this issue Aug 30, 2021
@quarkus-bot quarkus-bot bot added this to the 2.3 - main milestone Aug 31, 2021
@gsmet gsmet modified the milestones: 2.3 - main, 2.2.1.Final Aug 31, 2021
gsmet pushed a commit that referenced this issue Aug 31, 2021
Fixes #19621

(cherry picked from commit 9c55363)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
4 participants