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

Blockhound flags a blocking call when WebFlux serves a static resource #26631

Closed
JanVdloock opened this issue Mar 2, 2021 · 3 comments
Closed
Assignees
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) type: enhancement A general enhancement
Milestone

Comments

@JanVdloock
Copy link

Using Spring Boot WebFlux 2.4.3, there are blocking calls, detected by BlockHound when properties are loaded during the call.
Program was run with JDK 11 on Windows 10.

A simple program is attached. It contains a few static images, but when a unexisting image is requested, BlockHound detects a blocking call when the framework reads a properties file, to find the configuration for the error handling.

See the test class in the attached program.

spring-reactor-webflux-blockhound properties.zip

@wilkinsona
Copy link
Member

Thanks @JanVdloock. As discussed on Gitter this should be a Framework issue. We’ll transfer it over.

@philwebb philwebb transferred this issue from spring-projects/spring-boot Mar 2, 2021
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Mar 2, 2021
@rstoyanchev
Copy link
Contributor

From Gitter:

Having Spring Boot 2.4.3 with webflux and BlockHound.install(), getting static content (e.g. /error.png) throws a blocking call exception from BlockHound :

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 "/error.png" [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:1298) ~[na:na]
at java.base/java.util.zip.ZipFile$ZipFileInputStream.initDataOffset(ZipFile.java:997) ~[na:na]
at java.base/java.util.zip.ZipFile$ZipFileInputStream.read(ZipFile.java:1012) ~[na:na]
at java.base/java.util.zip.ZipFile$ZipFileInflaterInputStream.fill(ZipFile.java:467) ~[na:na]
at java.base/java.util.zip.InflaterInputStream.read(InflaterInputStream.java:159) ~[na:na]
at java.base/java.io.FilterInputStream.read(FilterInputStream.java:133) ~[na:na]
at java.base/sun.nio.cs.StreamDecoder.readBytes(StreamDecoder.java:284) ~[na:na]
at java.base/sun.nio.cs.StreamDecoder.implRead(StreamDecoder.java:326) ~[na:na]
at java.base/sun.nio.cs.StreamDecoder.read(StreamDecoder.java:178) ~[na:na]
at java.base/java.io.InputStreamReader.read(InputStreamReader.java:185) ~[na:na]
at java.base/java.io.BufferedReader.fill(BufferedReader.java:161) ~[na:na]
at java.base/java.io.BufferedReader.readLine(BufferedReader.java:326) ~[na:na]
at java.base/java.io.BufferedReader.readLine(BufferedReader.java:392) ~[na:na]
at org.springframework.http.MediaTypeFactory.parseMimeTypes(MediaTypeFactory.java:71) ~[spring-web-5.3.4.jar:5.3.4]
at org.springframework.http.MediaTypeFactory.<clinit>(MediaTypeFactory.java:47) ~[spring-web-5.3.4.jar:5.3.4]
at org.springframework.web.reactive.resource.ResourceWebHandler.getMediaType(ResourceWebHandler.java:579) ~[spring-webflux-5.3.4.jar:5.3.4]
at org.springframework.web.reactive.resource.ResourceWebHandler.lambda$handle$2(ResourceWebHandler.java:407) ~[spring-webflux-5.3.4.jar:5.3.4]
at reactor.core.publisher.MonoFlatMap$FlatMapMain.onNext(MonoFlatMap.java:125) ~[reactor-core-3.4.3.jar:3.4.3]
at reactor.core.publisher.FluxSwitchIfEmpty$SwitchIfEmptySubscriber.onNext(FluxSwitchIfEmpty.java:73) ~[reactor-core-3.4.3.jar:3.4.3]

@rstoyanchev rstoyanchev self-assigned this Mar 5, 2021
@rstoyanchev rstoyanchev added in: web Issues in web modules (web, webmvc, webflux, websocket) type: enhancement A general enhancement and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Mar 5, 2021
@rstoyanchev
Copy link
Contributor

rstoyanchev commented Mar 5, 2021

We can create a Blockhound rule to suppress it since this only happens once.

@rstoyanchev rstoyanchev changed the title Spring Boot Webflux has a blocking call while reading properties when unexisting static content is requested Blockhound flags a blocking call when WebFlux serves a static resource Mar 5, 2021
@rstoyanchev rstoyanchev modified the milestones: 5.3.9, 5.3.10 Jul 9, 2021
lxbzmy pushed a commit to lxbzmy/spring-framework that referenced this issue Mar 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

4 participants