Java Spring 5 WebClient |禁止连接拒绝异常日志记录
如何在以下客户端http调用中抑制日志记录连接被拒绝的异常Java Spring 5 WebClient |禁止连接拒绝异常日志记录,java,spring,spring-webflux,Java,Spring,Spring Webflux,如何在以下客户端http调用中抑制日志记录连接被拒绝的异常 return WebClient.create("http://anyurl") .get() .uri(builder -> { return builder.path("/somePath") .queryParam("...", ...) .build(); }) .retrieve() .bodyToFl
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?
.onErrorResume(e -> Flux.empty())
.map(this::myMappingMethod)
.collectList()
.block();
我已经在链中应用了onerrorsume()
,但仍然记录了错误:
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
它确实将错误转换为一个空通量,但看起来它也在记录它。我不能确定,但它看起来像是在记录错误严重性;如果是这样的话,您可能应该提交一个bug,因为这肯定没有那么严重。我按照您的建议提交了一个bug: