Skip to content

WebClient | onErrorResume logs exception although it has been handled [SPR-16484] #21027

@spring-projects-issues

Description

@spring-projects-issues

Marc-Christian Schulze opened SPR-16484 and commented

Given the following example:

return WebClient.create("http://anyurl")
    .get()
    .uri(builder -> {
        return builder.path("/somePath")
                .queryParam("...", ...)
                .build();
    })
    .retrieve()
    .bodyToFlux(AnyPojo.class)
    // shouldn't this convert any error in an empty Flux and suppress the error logging?
    .onErrorResume(e -> Flux.empty())
    .map(this::myMappingMethod)
    .collectList()
    .block();

Expected behaviour:

  • returns empty Flux
  • no exception thrown or logged

Actual Behaviour:

  • returns empty Flux
  • no exception thrown BUT logged with severity ERROR

Example Logs:

07:31:51.997 [reactor-http-nio-5] ERROR o.s.web.reactive.function.client - onError(io.netty.channel.AbstractChannel$AnnotatedConnectException: Connection refused: 068933adf361/172.17.0.2:80)
07:31:51.998 [reactor-http-nio-5] ERROR o.s.web.reactive.function.client -
io.netty.channel.AbstractChannel$AnnotatedConnectException: Connection refused: 068933adf361/172.17.0.2:80
    at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
    at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:717)
    at io.netty.channel.socket.nio.NioSocketChannel.doFinishConnect(NioSocketChannel.java:352)
    at io.netty.channel.nio.AbstractNioChannel$AbstractNioUnsafe.finishConnect(AbstractNioChannel.java:340)
    at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:612)
    at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:559)
    at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:476)
    at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:438)
    at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:858)
    at java.lang.Thread.run(Thread.java:748)
Caused by: java.net.ConnectException: Connection refused
    ... 10 common frames omitted

Logging uncaught errors with severity ERROR seems to be good thing but I would expect that errors that have been handled by user code are no longer logged.


Affects: 5.0.3

Metadata

Metadata

Assignees

Labels

in: webIssues in web modules (web, webmvc, webflux, websocket)type: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions