我有两个正在进行webrequest的Mono,我使用Mono.zip来合并结果。如果其中一个请求出错,我尝试使用onErrorMap处理错误,以转换我的自定义WebExceptionHandler将要处理的异常。但通过这样做,我得到了这个异常,这个异常不是由Reactor处理的:
reactor.core.Exceptions$BubblingException: javax.net.ssl.SSLException: SSLEngine closed already
at reactor.core.Exceptions.bubble(Exceptions.java:154) ~[reactor-core-3.1.2.RELEASE.jar:3.1.2.RELEASE]
at reactor.core.publisher.Operators.onErrorDropped(Operators.java:256) ~[reactor-core-3.1.2.RELEASE.jar:3.1.2.RELEASE]
at reactor.core.publisher.MonoCreate$DefaultMonoSink.error(MonoCreate.java:166) ~[reactor-core-3.1.2.RELEASE.jar:3.1.2.RELEASE]
at reactor.ipc.netty.channel.ContextHandler.fireContextError(ContextHandler.java:272) ~[reactor-netty-0.7.2.RELEASE.jar:0.7.2.RELEASE]
at reactor.ipc.netty.http.client.HttpClientOperations.onOutboundError(HttpClientOperations.java:502) [reactor-netty-0.7.2.RELEASE.jar:0.7.2.RELEASE]
at reactor.ipc.netty.channel.ChannelOperations.onError(ChannelOperations.java:232) ~[reactor-netty-0.7.2.RELEASE.jar:0.7.2.RELEASE]
at reactor.core.publisher.Operators$MultiSubscriptionSubscriber.onError(Operators.java:1332) ~[reactor-core-3.1.2.RELEASE.jar:3.1.2.RELEASE]
at reactor.core.publisher.Operators$MonoSubscriber.onError(Operators.java:1135) ~[reactor-core-3.1.2.RELEASE.jar:3.1.2.RELEASE]
at reactor.core.publisher.MonoIgnoreThen$ThenIgnoreInner.onError(MonoIgnoreThen.java:229) ~[reactor-core-3.1.2.RELEASE.jar:3.1.2.RELEASE]
at reactor.ipc.netty.FutureMono$FutureSubscription.operationComplete(FutureMono.java:159) ~[reactor-netty-0.7.2.RELEASE.jar:0.7.2.RELEASE]
at io.netty.util.concurrent.DefaultPromise.notifyListener0(DefaultPromise.java:507) [netty-common-4.1.17.Final.jar:4.1.17.Final]
at io.netty.util.concurrent.DefaultPromise.notifyListenersNow(DefaultPromise.java:481) [netty-common-4.1.17.Final.jar:4.1.17.Final]
at io.netty.util.concurrent.DefaultPromise.notifyListeners(DefaultPromise.java:420) [netty-common-4.1.17.Final.jar:4.1.17.Final]
at io.netty.util.concurrent.DefaultPromise.tryFailure(DefaultPromise.java:122) [netty-common-4.1.17.Final.jar:4.1.17.Final]
at io.netty.util.internal.PromiseNotificationUtil.tryFailure(PromiseNotificationUtil.java:64) [netty-common-4.1.17.Final.jar:4.1.17.Final]
at io.netty.channel.DelegatingChannelPromiseNotifier.operationComplete(DelegatingChannelPromiseNotifier.java:57) [netty-transport-4.1.17.Final.jar:4.1.17.Final]
at io.netty.channel.DelegatingChannelPromiseNotifier.operationComplete(DelegatingChannelPromiseNotifier.java:31) [netty-transport-4.1.17.Final.jar:4.1.17.Final]
at io.netty.util.concurrent.DefaultPromise.notifyListener0(DefaultPromise.java:507) [netty-common-4.1.17.Final.jar:4.1.17.Final]
at io.netty.util.concurrent.DefaultPromise.notifyListenersNow(DefaultPromise.java:481) [netty-common-4.1.17.Final.jar:4.1.17.Final]
at io.netty.util.concurrent.DefaultPromise.notifyListeners(DefaultPromise.java:420) [netty-common-4.1.17.Final.jar:4.1.17.Final]
at io.netty.util.concurrent.DefaultPromise.tryFailure(DefaultPromise.java:122) [netty-common-4.1.17.Final.jar:4.1.17.Final]
at io.netty.util.internal.PromiseNotificationUtil.tryFailure(PromiseNotificationUtil.java:64) [netty-common-4.1.17.Final.jar:4.1.17.Final]
at io.netty.channel.DelegatingChannelPromiseNotifier.operationComplete(DelegatingChannelPromiseNotifier.java:57) [netty-transport-4.1.17.Final.jar:4.1.17.Final]
at io.netty.channel.DelegatingChannelPromiseNotifier.operationComplete(DelegatingChannelPromiseNotifier.java:31) [netty-transport-4.1.17.Final.jar:4.1.17.Final]
at io.netty.util.concurrent.DefaultPromise.notifyListener0(DefaultPromise.java:507) [netty-common-4.1.17.Final.jar:4.1.17.Final]
at io.netty.util.concurrent.DefaultPromise.notifyListeners0(DefaultPromise.java:500) [netty-common-4.1.17.Final.jar:4.1.17.Final]
at io.netty.util.concurrent.DefaultPromise.notifyListenersNow(DefaultPromise.java:479) [netty-common-4.1.17.Final.jar:4.1.17.Final]
at io.netty.util.concurrent.DefaultPromise.notifyListeners(DefaultPromise.java:420) [netty-common-4.1.17.Final.jar:4.1.17.Final]
at io.netty.util.concurrent.DefaultPromise.tryFailure(DefaultPromise.java:122) [netty-common-4.1.17.Final.jar:4.1.17.Final]
at io.netty.handler.ssl.SslHandler.wrap(SslHandler.java:789) [netty-handler-4.1.17.Final.jar:4.1.17.Final]
at io.netty.handler.ssl.SslHandler.wrapAndFlush(SslHandler.java:752) [netty-handler-4.1.17.Final.jar:4.1.17.Final]
at io.netty.handler.ssl.SslHandler.flush(SslHandler.java:733) [netty-handler-4.1.17.Final.jar:4.1.17.Final]
at io.netty.handler.ssl.SslHandler.flush(SslHandler.java:1586) [netty-handler-4.1.17.Final.jar:4.1.17.Final]
at io.netty.handler.ssl.SslHandler.closeOutboundAndChannel(SslHandler.java:1565) [netty-handler-4.1.17.Final.jar:4.1.17.Final]
at io.netty.handler.ssl.SslHandler.close(SslHandler.java:691) [netty-handler-4.1.17.Final.jar:4.1.17.Final]
at io.netty.channel.AbstractChannelHandlerContext.invokeClose(AbstractChannelHandlerContext.java:624) [netty-transport-4.1.17.Final.jar:4.1.17.Final]
at io.netty.channel.AbstractChannelHandlerContext.close(AbstractChannelHandlerContext.java:608) [netty-transport-4.1.17.Final.jar:4.1.17.Final]
at io.netty.handler.logging.LoggingHandler.close(LoggingHandler.java:217) [netty-handler-4.1.17.Final.jar:4.1.17.Final]
at io.netty.channel.AbstractChannelHandlerContext.invokeClose(AbstractChannelHandlerContext.java:624) [netty-transport-4.1.17.Final.jar:4.1.17.Final]
at io.netty.channel.AbstractChannelHandlerContext.close(AbstractChannelHandlerContext.java:608) [netty-transport-4.1.17.Final.jar:4.1.17.Final]
at io.netty.channel.CombinedChannelDuplexHandler$DelegatingChannelHandlerContext.close(CombinedChannelDuplexHandler.java:507) [netty-transport-4.1.17.Final.jar:4.1.17.Final]
at io.netty.channel.ChannelOutboundHandlerAdapter.close(ChannelOutboundHandlerAdapter.java:71) [netty-transport-4.1.17.Final.jar:4.1.17.Final]
at io.netty.channel.CombinedChannelDuplexHandler.close(CombinedChannelDuplexHandler.java:318) [netty-transport-4.1.17.Final.jar:4.1.17.Final]
at io.netty.channel.AbstractChannelHandlerContext.invokeClose(AbstractChannelHandlerContext.java:624) [netty-transport-4.1.17.Final.jar:4.1.17.Final]
at io.netty.channel.AbstractChannelHandlerContext.close(AbstractChannelHandlerContext.java:608) [netty-transport-4.1.17.Final.jar:4.1.17.Final]
at io.netty.channel.ChannelDuplexHandler.close(ChannelDuplexHandler.java:73) [netty-transport-4.1.17.Final.jar:4.1.17.Final]
at io.netty.channel.AbstractChannelHandlerContext.invokeClose(AbstractChannelHandlerContext.java:624) [netty-transport-4.1.17.Final.jar:4.1.17.Final]
at io.netty.channel.AbstractChannelHandlerContext.close(AbstractChannelHandlerContext.java:608) [netty-transport-4.1.17.Final.jar:4.1.17.Final]
at io.netty.channel.AbstractChannelHandlerContext.close(AbstractChannelHandlerContext.java:465) [netty-transport-4.1.17.Final.jar:4.1.17.Final]
at io.netty.channel.DefaultChannelPipeline.close(DefaultChannelPipeline.java:973) [netty-transport-4.1.17.Final.jar:4.1.17.Final]
at io.netty.channel.AbstractChannel.close(AbstractChannel.java:238) [netty-transport-4.1.17.Final.jar:4.1.17.Final]
at reactor.ipc.netty.http.client.HttpClientOperations.onInboundCancel(HttpClientOperations.java:256) [reactor-netty-0.7.2.RELEASE.jar:0.7.2.RELEASE]
at reactor.ipc.netty.channel.FluxReceive.unsubscribeReceiver(FluxReceive.java:385) [reactor-netty-0.7.2.RELEASE.jar:0.7.2.RELEASE]
at reactor.ipc.netty.channel.FluxReceive.lambda$new$0(FluxReceive.java:67) [reactor-netty-0.7.2.RELEASE.jar:0.7.2.RELEASE]
at reactor.ipc.netty.channel.FluxReceive.cancelReceiver(FluxReceive.java:136) [reactor-netty-0.7.2.RELEASE.jar:0.7.2.RELEASE]
at reactor.ipc.netty.channel.FluxReceive.cancel(FluxReceive.java:77) [reactor-netty-0.7.2.RELEASE.jar:0.7.2.RELEASE]
at reactor.ipc.netty.channel.PooledClientContextHandler.disposeOperationThenRelease(PooledClientContextHandler.java:251) ~[reactor-netty-0.7.2.RELEASE.jar:0.7.2.RELEASE]
at reactor.ipc.netty.channel.PooledClientContextHandler.lambda$dispose$2(PooledClientContextHandler.java:233) ~[reactor-netty-0.7.2.RELEASE.jar:0.7.2.RELEASE]
at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:163) ~[netty-common-4.1.17.Final.jar:4.1.17.Final]
at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:403) ~[netty-common-4.1.17.Final.jar:4.1.17.Final]
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:463) ~[netty-transport-4.1.17.Final.jar:4.1.17.Final]
at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:858) ~[netty-common-4.1.17.Final.jar:4.1.17.Final]
at java.lang.Thread.run(Thread.java:745) ~[na:1.8.0_112]
Caused by: javax.net.ssl.SSLException: SSLEngine closed already
at io.netty.handler.ssl.SslHandler.wrap(...)(Unknown Source) [netty-handler-4.1.17.Final.jar:4.1.17.Final]
我想这是因为我取消了错误导致冒泡定义的请求
例如:
private fun <T> createMono(clientResponse: ClientResponse, tClass: Class<T>): Mono<T> {
return if (clientResponse.statusCode().value() != 200) {
Mono.error<T>(RestClientException(clientResponse, errorMapper))
} else if (!clientResponse.headers().contentType().isPresent) {
Mono.empty<T>()
} else {
clientResponse.bodyToMono(tClass)
}
}
fun getResponse(serverRequest: ServerRequest): Mono<ServerResponse>{
val mono1 : Mono<Foo> = WebClient....flatMap { clientResponse -> createMono(clientResponse, Foo.class) }
val mono2 : Mono<Bar> = WebClient....flatMap { clientResponse -> createMono(clientResponse, Bar.class) }
return ServerResponse.ok().body(Mono.zip(mono0, mono1)
.map {mymappinfunction(it)}
.onErrorMap { ex -> MyCustomException(ex) },MyClass::class.java)
}
答案 0 :(得分:0)
我已迁移到spring boot m7(之前是m6),我无法重现此错误