Vertx-web: OpenAPI3RouterBuilder with BodyHandler and AuthenticationHandler using HTTP2 cause "java.lang.IllegalStateException: Request has already been read"

Created on 26 Nov 2020  Â·  11Comments  Â·  Source: vert-x3/vertx-web

Version

4.0.0.CR2 (caused by this commit https://github.com/vert-x3/vertx-web/commit/937d1e73bda0e90789a9ced17ec2c5a800bdbf0b)

Context

Using RouterBuilder (swagger file) with HttpServer and ALPN (HTTP2)

Do you have a reproducer?

https://github.com/DemonicTutor/vertx-web-openapi-http2

Steps to reproduce

  1. Router using RouterBuilder and swagger API definition
  2. AuthenticationHandler (eg: BasicAuth)
  3. HttpServer with ALPN / HTTP2
  4. Execute a request
  5. AuthenticationHandler throws java.lang.IllegalStateException: Request has already been read

Extra

openJdk 15

What happens

OpenApi3 RouterBuilder adds the BodyHandler as the first handler

https://github.com/vert-x3/vertx-web/blob/master/vertx-web-openapi/src/main/java/io/vertx/ext/web/openapi/impl/OpenAPI3RouterBuilderImpl.java#L241

... later the AuthenticationHandler

BodyHandler reads the headers

https://github.com/vert-x3/vertx-web/blob/master/vertx-web/src/main/java/io/vertx/ext/web/handler/impl/BodyHandlerImpl.java#L77

AuthenticationHandler wants to pause()

https://github.com/vert-x3/vertx-web/blob/master/vertx-web/src/main/java/io/vertx/ext/web/handler/impl/AuthenticationHandlerImpl.java#L75

Http2ServerRequest blows up

https://github.com/eclipse-vertx/vert.x/blob/4.0.0.CR2/src/main/java/io/vertx/core/http/impl/Http2ServerRequestImpl.java#L261

bug

Most helpful comment

@therockstorm that must be another issue. I just run @DemonicTutor reproducer: https://github.com/DemonicTutor/vertx-web-openapi-http2 replacing the version from 4.0.0.CR2 to 4.0.2 makes the test pass.

@therockstorm I'll close this issue as it is fixed, but please open a new one for your upload case. Check the reproducer from @DemonicTutor and see if you can add your case with the failure, so it makes it easier for us to fix!

All 11 comments

@pmlopes can you check this one?

I like your GitHub handle @DemonicTutor :-)

@vietj thanks... played a lot WotC - Magic the Gathering when in school :)

only a few picked a nickname after a (powerful) card :-)

On Tue, Dec 8, 2020 at 10:37 AM DemonicTutor notifications@github.com
wrote:

@vietj https://github.com/vietj thanks... played a lot WotC - Magic the
Gathering
https://static.cardmarket.com/img/a831528c54b99c06949089f8e79959a7/items/1/JR/428076.jpg
when in school :)

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/vert-x3/vertx-web/issues/1797#issuecomment-740503972,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/AABXDCTVGJ2GUZVPPZFFKADSTXXT5ANCNFSM4UDTF6WQ
.

Haven't met a BlackLotus yet :)

@vietj @slinkydeveloper @pmlopes

Hey!

Got any insight on this one?

Also.. if you can provide me your view on the issue - how to approach it - i could take a stab at it.

But from my point of view its not a good idea to allow a Handler to change state of a shared resource (the Request) so i am at a loss where you want to go with this.

We're waiting on this fix too, it's preventing us from updating to 4.0.0.

@DemonicTutor @therockstorm could you have a check on this with 4.0.2 as many fixes have been added, and pause/resume on auth handlers too.

Maybe this is a different issue, but updating to 4.0.0 - 4.0.2 breaks our file upload tests, they just hang. So we're stuck on 4.0.0.CR1.

@therockstorm that must be another issue. I just run @DemonicTutor reproducer: https://github.com/DemonicTutor/vertx-web-openapi-http2 replacing the version from 4.0.0.CR2 to 4.0.2 makes the test pass.

@therockstorm I'll close this issue as it is fixed, but please open a new one for your upload case. Check the reproducer from @DemonicTutor and see if you can add your case with the failure, so it makes it easier for us to fix!

@pmlopes thanks for checking! :)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

AshtonKem picture AshtonKem  Â·  6Comments

elR1co picture elR1co  Â·  4Comments

purplefox picture purplefox  Â·  8Comments

LLfam picture LLfam  Â·  4Comments

violette picture violette  Â·  6Comments