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

Error with blockhound and springdoc-openapi-webflux-ui #1205

Closed
sickan90 opened this issue Jul 1, 2021 · 5 comments
Closed

Error with blockhound and springdoc-openapi-webflux-ui #1205

sickan90 opened this issue Jul 1, 2021 · 5 comments

Comments

@sickan90
Copy link

sickan90 commented Jul 1, 2021

Describe the bug
If you add BlockHound to the project you are not able to navigate to the swagger doc as it will report that it is using a blocking call.

2021-07-01 15:37:59.104 ERROR 11476 --- [ctor-http-nio-2] a.w.r.e.AbstractErrorWebExceptionHandler : [c3451dd8-2]  500 Server Error for HTTP GET "/webjars/swagger-ui/index.html?configUrl=/v3/api-docs/swagger-config"

reactor.blockhound.BlockingOperationError: Blocking call! java.io.RandomAccessFile#readBytes
        at java.base/java.io.RandomAccessFile.readBytes(RandomAccessFile.java) ~[na:na]
        Suppressed: reactor.core.publisher.FluxOnAssembly$OnAssemblyException:
Error has been observed at the following site(s):
        |_ checkpoint ? HTTP GET "/webjars/swagger-ui/index.html?configUrl=/v3/api-docs/swagger-config" [ExceptionHandlingWebHandler]
Stack trace:
                at java.base/java.io.RandomAccessFile.readBytes(RandomAccessFile.java) ~[na:na]
                at java.base/java.io.RandomAccessFile.read(RandomAccessFile.java:406) ~[na:na]
                at java.base/java.io.RandomAccessFile.readFully(RandomAccessFile.java:470) ~[na:na]
                at java.base/java.util.zip.ZipFile$Source.readFullyAt(ZipFile.java:1304) ~[na:na]
                at java.base/java.util.zip.ZipFile$ZipFileInputStream.initDataOffset(ZipFile.java:998) ~[na:na]
                at java.base/java.util.zip.ZipFile$ZipFileInputStream.read(ZipFile.java:1013) ~[na:na]
                at java.base/java.util.zip.ZipFile$ZipFileInflaterInputStream.fill(ZipFile.java:468) ~[na:na]
                at java.base/java.util.zip.InflaterInputStream.read(InflaterInputStream.java:159) ~[na:na]
                at java.base/java.io.InputStream.readNBytes(InputStream.java:490) ~[na:na]
                at java.base/java.util.jar.JarFile.getBytes(JarFile.java:807) ~[na:na]
                at java.base/java.util.jar.JarFile.checkForSpecialAttributes(JarFile.java:1007) ~[na:na]
                at java.base/java.util.jar.JarFile.isMultiRelease(JarFile.java:390) ~[na:na]
                at java.base/java.util.jar.JarFile.getEntry(JarFile.java:509) ~[na:na]
                at java.base/sun.net.www.protocol.jar.URLJarFile.getEntry(URLJarFile.java:131) ~[na:na]
                at java.base/sun.net.www.protocol.jar.JarURLConnection.connect(JarURLConnection.java:137) ~[na:na]
                at java.base/sun.net.www.protocol.jar.JarURLConnection.getContentLengthLong(JarURLConnection.java:182) ~[na:na]
                at org.springframework.core.io.AbstractFileResolvingResource.isReadable(AbstractFileResolvingResource.java:109) ~[spring-core-5.3.8.jar:5.3.8]
                at org.springframework.web.reactive.resource.PathResourceResolver.getResource(PathResourceResolver.java:117) ~[spring-webflux-5.3.8.jar:5.3.8]
                at org.springframework.web.reactive.resource.PathResourceResolver.lambda$getResource$1(PathResourceResolver.java:99) ~[spring-webflux-5.3.8.jar:5.3.8]
                at reactor.core.publisher.FluxConcatMap$ConcatMapImmediate.drain(FluxConcatMap.java:374) ~[reactor-core-3.4.7.jar:3.4.7]
                at reactor.core.publisher.FluxConcatMap$ConcatMapImmediate.onSubscribe(FluxConcatMap.java:218) ~[reactor-core-3.4.7.jar:3.4.7]
                at reactor.core.publisher.FluxIterable.subscribe(FluxIterable.java:164) ~[reactor-core-3.4.7.jar:3.4.7]
                at reactor.core.publisher.FluxIterable.subscribe(FluxIterable.java:86) ~[reactor-core-3.4.7.jar:3.4.7]
                at reactor.core.publisher.MonoFromFluxOperator.subscribe(MonoFromFluxOperator.java:81) ~[reactor-core-3.4.7.jar:3.4.7]
                at reactor.core.publisher.MonoDefer.subscribe(MonoDefer.java:52) ~[reactor-core-3.4.7.jar:3.4.7]
                at reactor.core.publisher.Mono.subscribe(Mono.java:4150) ~[reactor-core-3.4.7.jar:3.4.7]
                at reactor.core.publisher.FluxSwitchIfEmpty$SwitchIfEmptySubscriber.onComplete(FluxSwitchIfEmpty.java:81) ~[reactor-core-3.4.7.jar:3.4.7]
                at reactor.core.publisher.MonoNext$NextSubscriber.onComplete(MonoNext.java:102) ~[reactor-core-3.4.7.jar:3.4.7]
                at reactor.core.publisher.FluxConcatMap$ConcatMapImmediate.drain(FluxConcatMap.java:366) ~[reactor-core-3.4.7.jar:3.4.7]
                at reactor.core.publisher.FluxConcatMap$ConcatMapImmediate.onSubscribe(FluxConcatMap.java:218) ~[reactor-core-3.4.7.jar:3.4.7]
                at reactor.core.publisher.FluxIterable.subscribe(FluxIterable.java:164) ~[reactor-core-3.4.7.jar:3.4.7]
                at reactor.core.publisher.FluxIterable.subscribe(FluxIterable.java:86) ~[reactor-core-3.4.7.jar:3.4.7]
                at reactor.core.publisher.Mono.subscribe(Mono.java:4150) ~[reactor-core-3.4.7.jar:3.4.7]
                at reactor.core.publisher.MonoIgnoreThen$ThenIgnoreMain.subscribeNext(MonoIgnoreThen.java:255) ~[reactor-core-3.4.7.jar:3.4.7]
                at reactor.core.publisher.MonoIgnoreThen.subscribe(MonoIgnoreThen.java:51) ~[reactor-core-3.4.7.jar:3.4.7]
                at reactor.core.publisher.MonoFlatMap$FlatMapMain.onNext(MonoFlatMap.java:157) ~[reactor-core-3.4.7.jar:3.4.7]
                at reactor.core.publisher.FluxSwitchIfEmpty$SwitchIfEmptySubscriber.onNext(FluxSwitchIfEmpty.java:73) ~[reactor-core-3.4.7.jar:3.4.7]
                at reactor.core.publisher.MonoNext$NextSubscriber.onNext(MonoNext.java:82) ~[reactor-core-3.4.7.jar:3.4.7]
                at reactor.core.publisher.FluxConcatMap$ConcatMapImmediate.innerNext(FluxConcatMap.java:281) ~[reactor-core-3.4.7.jar:3.4.7]
                at reactor.core.publisher.FluxConcatMap$ConcatMapInner.onNext(FluxConcatMap.java:860) ~[reactor-core-3.4.7.jar:3.4.7]
                at reactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber.onNext(FluxMapFuseable.java:127) ~[reactor-core-3.4.7.jar:3.4.7]
                at reactor.core.publisher.Operators$ScalarSubscription.request(Operators.java:2397) ~[reactor-core-3.4.7.jar:3.4.7]
                at reactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber.request(FluxMapFuseable.java:169) ~[reactor-core-3.4.7.jar:3.4.7]
                at reactor.core.publisher.Operators$MultiSubscriptionSubscriber.set(Operators.java:2193) ~[reactor-core-3.4.7.jar:3.4.7]
                at reactor.core.publisher.Operators$MultiSubscriptionSubscriber.onSubscribe(Operators.java:2067) ~[reactor-core-3.4.7.jar:3.4.7]
                at reactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber.onSubscribe(FluxMapFuseable.java:96) ~[reactor-core-3.4.7.jar:3.4.7]
                at reactor.core.publisher.MonoJust.subscribe(MonoJust.java:54) ~[reactor-core-3.4.7.jar:3.4.7]
                at reactor.core.publisher.Mono.subscribe(Mono.java:4150) ~[reactor-core-3.4.7.jar:3.4.7]
                at reactor.core.publisher.FluxConcatMap$ConcatMapImmediate.drain(FluxConcatMap.java:448) ~[reactor-core-3.4.7.jar:3.4.7]
                at reactor.core.publisher.FluxConcatMap$ConcatMapImmediate.onSubscribe(FluxConcatMap.java:218) ~[reactor-core-3.4.7.jar:3.4.7]
                at reactor.core.publisher.FluxIterable.subscribe(FluxIterable.java:164) ~[reactor-core-3.4.7.jar:3.4.7]
                at reactor.core.publisher.FluxIterable.subscribe(FluxIterable.java:86) ~[reactor-core-3.4.7.jar:3.4.7]
                at reactor.core.publisher.InternalMonoOperator.subscribe(InternalMonoOperator.java:64) ~[reactor-core-3.4.7.jar:3.4.7]
                at reactor.core.publisher.MonoDefer.subscribe(MonoDefer.java:52) ~[reactor-core-3.4.7.jar:3.4.7]
                at reactor.core.publisher.Mono.subscribe(Mono.java:4150) ~[reactor-core-3.4.7.jar:3.4.7]
                at reactor.core.publisher.MonoIgnoreThen$ThenIgnoreMain.subscribeNext(MonoIgnoreThen.java:255) ~[reactor-core-3.4.7.jar:3.4.7]
                at reactor.core.publisher.MonoIgnoreThen.subscribe(MonoIgnoreThen.java:51) ~[reactor-core-3.4.7.jar:3.4.7]
                at reactor.core.publisher.InternalMonoOperator.subscribe(InternalMonoOperator.java:64) ~[reactor-core-3.4.7.jar:3.4.7]
                at reactor.netty.http.server.HttpServer$HttpServerHandle.onStateChange(HttpServer.java:915) ~[reactor-netty-http-1.0.8.jar:1.0.8]
                at reactor.netty.ReactorNetty$CompositeConnectionObserver.onStateChange(ReactorNetty.java:654) ~[reactor-netty-core-1.0.8.jar:1.0.8]
                at reactor.netty.transport.ServerTransport$ChildObserver.onStateChange(ServerTransport.java:478) ~[reactor-netty-core-1.0.8.jar:1.0.8]
                at reactor.netty.http.server.HttpServerOperations.onInboundNext(HttpServerOperations.java:533) ~[reactor-netty-http-1.0.8.jar:1.0.8]
                at reactor.netty.channel.ChannelOperationsHandler.channelRead(ChannelOperationsHandler.java:94) ~[reactor-netty-core-1.0.8.jar:1.0.8]
                at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) ~[netty-transport-4.1.65.Final.jar:4.1.65.Final]
                at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) ~[netty-transport-4.1.65.Final.jar:4.1.65.Final]
                at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357) ~[netty-transport-4.1.65.Final.jar:4.1.65.Final]
                at reactor.netty.http.server.HttpTrafficHandler.channelRead(HttpTrafficHandler.java:209) ~[reactor-netty-http-1.0.8.jar:1.0.8]
                at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) ~[netty-transport-4.1.65.Final.jar:4.1.65.Final]
                at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) ~[netty-transport-4.1.65.Final.jar:4.1.65.Final]
                at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357) ~[netty-transport-4.1.65.Final.jar:4.1.65.Final]
                at io.netty.channel.CombinedChannelDuplexHandler$DelegatingChannelHandlerContext.fireChannelRead(CombinedChannelDuplexHandler.java:436) ~[netty-transport-4.1.65.Final.jar:4.1.65.Final]
                at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:324) ~[netty-codec-4.1.65.Final.jar:4.1.65.Final]
                at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:296) ~[netty-codec-4.1.65.Final.jar:4.1.65.Final]
                at io.netty.channel.CombinedChannelDuplexHandler.channelRead(CombinedChannelDuplexHandler.java:251) ~[netty-transport-4.1.65.Final.jar:4.1.65.Final]
                at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) ~[netty-transport-4.1.65.Final.jar:4.1.65.Final]
                at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) ~[netty-transport-4.1.65.Final.jar:4.1.65.Final]
                at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357) ~[netty-transport-4.1.65.Final.jar:4.1.65.Final]
                at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1410) ~[netty-transport-4.1.65.Final.jar:4.1.65.Final]
                at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) ~[netty-transport-4.1.65.Final.jar:4.1.65.Final]
                at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) ~[netty-transport-4.1.65.Final.jar:4.1.65.Final]
                at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:919) ~[netty-transport-4.1.65.Final.jar:4.1.65.Final]
                at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:166) ~[netty-transport-4.1.65.Final.jar:4.1.65.Final]
                at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:719) ~[netty-transport-4.1.65.Final.jar:4.1.65.Final]
                at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:655) ~[netty-transport-4.1.65.Final.jar:4.1.65.Final]
                at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:581) ~[netty-transport-4.1.65.Final.jar:4.1.65.Final]
                at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:493) ~[netty-transport-4.1.65.Final.jar:4.1.65.Final]
                at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989) ~[netty-common-4.1.65.Final.jar:4.1.65.Final]
                at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) ~[netty-common-4.1.65.Final.jar:4.1.65.Final]
                at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) ~[netty-common-4.1.65.Final.jar:4.1.65.Final]
                at java.base/java.lang.Thread.run(Thread.java:834) ~[na:na]

To Reproduce
Steps to reproduce the behavior:

Expected behavior

  • Should work without any blocking calls

Additional context
This issue has been reported before #884. I have tried that example as well and getting the same error with it. Don't understand why it was said that that example was working fine.

@bnasslahsen
Copy link
Contributor

bnasslahsen commented Jul 13, 2021

@sickan90,

Use the following syntax to allow a getBytes which is containing a blocking call:

BlockHound.install(b -> b.allowBlockingCallsInside(InflaterInputStream.class.getName(), "read"));

@akshayvadher
Copy link

akshayvadher commented Jan 21, 2022

@sickan90,

Use the following syntax to allow a getBytes which is containing a blocking call:

BlockHound.install(b -> b.allowBlockingCallsInside(InflaterInputStream.class.getName(), "read"));

@bnasslahsen
Hope this does not allow any actual blocking calls. In other words, the class InflaterInputStream, are we sure that is being used only for swagger?

@bnasslahsen
Copy link
Contributor

@akshayvadher,

This is used for sure in swagger.
Elsewhere depends on your code.. .
If you have the call elsewhere, you are going to get the same error.

@akshayvadher
Copy link

The problem is, someone might actually using InflaterInputStream in code and hence blocking the thread. Since we allowed it for swagger, essentially we introduced a bug.

Question is, do we have a way to allow blocking calls only for swagger?

@bnasslahsen
Copy link
Contributor

@akshayvadher,

See the previous answer and you can adapt it.

@springdoc springdoc locked as too heated and limited conversation to collaborators Jan 21, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants