vert-x3 / vertx-web

HTTP web applications for Vert.x
Apache License 2.0
1.11k stars 535 forks source link

Invalid URL scheme reported to the Vert.x exception handler instead of the returned future #2060

Open cescoffier opened 3 years ago

cescoffier commented 3 years ago

Bug

Invalid schemes are not reported to the future, but directly to the Vert.x exception handler.

2021-10-04 07:46:44,150 ERROR [io.qua.ver.cor.run.VertxCoreRecorder] (vert.x-eventloop-thread-0) Uncaught exception received by Vert.x: java.lang.RuntimeException: Failed to resolve path from https://raw.githubusercontent.com/murphye/vertx-web-openapi-quarkus-petstore/main/src/main/resources/META-INF/openapi.yaml
    at io.vertx.ext.web.openapi.impl.OpenAPIHolderImpl.uriToPath(OpenAPIHolderImpl.java:387)
    at io.vertx.ext.web.openapi.impl.OpenAPIHolderImpl.resolveContainingDirPath(OpenAPIHolderImpl.java:392)
    at io.vertx.ext.web.openapi.impl.OpenAPIHolderImpl.lambda$loadOpenAPI$0(OpenAPIHolderImpl.java:75)
    at io.vertx.core.impl.future.FutureImpl$1.onSuccess(FutureImpl.java:91)
    at io.vertx.core.impl.future.FutureImpl$ListenerArray.onSuccess(FutureImpl.java:262)
    at io.vertx.core.impl.future.FutureBase.emitSuccess(FutureBase.java:60)
    at io.vertx.core.impl.future.FutureImpl.tryComplete(FutureImpl.java:211)
    at io.vertx.core.impl.future.PromiseImpl.tryComplete(PromiseImpl.java:23)
    at io.vertx.core.Promise.complete(Promise.java:66)
    at io.vertx.ext.web.openapi.impl.OpenAPIHolderImpl.lambda$null$7(OpenAPIHolderImpl.java:317)
    at io.vertx.core.impl.future.FutureImpl$1.onSuccess(FutureImpl.java:91)
    at io.vertx.core.impl.future.FutureBase.lambda$emitSuccess$0(FutureBase.java:54)
    at io.vertx.core.impl.EventLoopContext.execute(EventLoopContext.java:81)
    at io.vertx.core.impl.ContextImpl.execute(ContextImpl.java:260)
    at io.vertx.core.impl.EventLoopContext.execute(EventLoopContext.java:22)
    at io.vertx.core.impl.future.FutureBase.emitSuccess(FutureBase.java:51)
    at io.vertx.core.impl.future.FutureImpl.tryComplete(FutureImpl.java:211)
    at io.vertx.core.impl.future.PromiseImpl.tryComplete(PromiseImpl.java:23)
    at io.vertx.core.http.impl.HttpEventHandler.handleEnd(HttpEventHandler.java:79)
    at io.vertx.core.http.impl.HttpClientResponseImpl.handleEnd(HttpClientResponseImpl.java:250)
    at io.vertx.core.http.impl.Http1xClientConnection$StreamImpl.lambda$new$0(Http1xClientConnection.java:373)
    at io.vertx.core.streams.impl.InboundBuffer.handleEvent(InboundBuffer.java:240)
    at io.vertx.core.streams.impl.InboundBuffer.write(InboundBuffer.java:130)
    at io.vertx.core.http.impl.Http1xClientConnection$StreamImpl.handleEnd(Http1xClientConnection.java:588)
    at io.vertx.core.impl.EventLoopContext.execute(EventLoopContext.java:71)
    at io.vertx.core.impl.ContextImpl.execute(ContextImpl.java:267)
    at io.vertx.core.http.impl.Http1xClientConnection.handleResponseEnd(Http1xClientConnection.java:822)
    at io.vertx.core.http.impl.Http1xClientConnection.handleHttpMessage(Http1xClientConnection.java:694)
    at io.vertx.core.http.impl.Http1xClientConnection.handleMessage(Http1xClientConnection.java:658)
    at io.vertx.core.net.impl.ConnectionBase.read(ConnectionBase.java:155)
    at io.vertx.core.net.impl.VertxHandler.channelRead(VertxHandler.java:154)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)
    at io.netty.channel.CombinedChannelDuplexHandler$DelegatingChannelHandlerContext.fireChannelRead(CombinedChannelDuplexHandler.java:436)
    at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:324)
    at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:296)
    at io.netty.channel.CombinedChannelDuplexHandler.channelRead(CombinedChannelDuplexHandler.java:251)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)
    at io.netty.handler.ssl.SslHandler.unwrap(SslHandler.java:1372)
    at io.netty.handler.ssl.SslHandler.decodeJdkCompatible(SslHandler.java:1235)
    at io.netty.handler.ssl.SslHandler.decode(SslHandler.java:1284)
    at io.netty.handler.codec.ByteToMessageDecoder.decodeRemovalReentryProtection(ByteToMessageDecoder.java:507)
    at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:446)
    at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:276)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)
    at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1410)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
    at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:919)
    at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:166)
    at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:719)
    at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:655)
    at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:581)
    at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:493)
    at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:986)
    at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
    at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
    at java.base/java.lang.Thread.run(Thread.java:833)
Caused by: java.lang.IllegalArgumentException: unsupported scheme type for 'https://raw.githubusercontent.com/murphye/vertx-web-openapi-quarkus-petstore/main/src/main/resources/META-INF/openapi.yaml'
    at io.vertx.ext.web.openapi.impl.OpenAPIHolderImpl.uriToPath(OpenAPIHolderImpl.java:384)
    ... 62 more

Version

4.1.3 without the possibility to switch to 4.2 for now.

Context

I encountered an exception which looks suspicious while ...

Do you have a reproducer?

A reproducer is a simple project hosted on GitHub (or another forge supporting git clone operation) that has a build file that can be executed to reproduce the issue.

Reproducers are very helpful for contributors and will likely help them fixing your bug faster.

See https://github.com/quarkusio/quarkus/issues/20423 which provides a reproducer.

Steps to reproduce

  1. With the reproducer from https://github.com/quarkusio/quarkus/issues/20423
  2. mvn quarkus:dev
  3. BOOM

The log indicates that the exception bypass the handler (which is waiting for the failure).

Extra

pmlopes commented 3 years ago

Already fixed by: https://github.com/vert-x3/vertx-web/pull/2035

but...

A proper and correct fix should land after https://github.com/eclipse-vertx/vert.x/pull/4099 is merged and the required changes land here.

pmlopes commented 3 years ago

We can backport the "quick" fix to 4.1 if needed, it's not complex.

kurt-o-sys commented 3 years ago

Has this been backported? We still have issues fetching openapi specs using https: #2073

(If not, please backport or make a new Beta-release?)