WebFlux 和 Spring-Integration 的奇怪错误 - IndexOutOfBoundsException 超过 maxCapacity

Strange error with WebFlux and Spring-Integration - IndexOutOfBoundsException exceeds maxCapacity

我正在编写 spring-integration 流程,旨在根据远程资源是否实际存在来丰富消息的 headers。

假设有一个 RESTful 端点,其上有一个 API,它将根据唯一名称找到一个 object:/mix-entity/name/{mixEntityName}.

此 API 将 return MixEntity { "id": 1, "name": "One" } 的 JSON 表示。

如果未找到 MixEntity,结果将为 HTTP/404。

HTTP/200 结果案例适用于此,但 404 案例是我苦苦挣扎的地方。我正在尝试以优雅的方式处理此案。

我的集成流程大致如下所示:

@Bean
public IntegrationFlow getMixEntryFlowReactive() {
    final WebClient webClient =
                        webClientBuilder.defaultHeaders(
                                        headers -> headers.setBasicAuth("api", "s3cr3t")
                                    )
                                    .build();
    return f->
            f.enrich(
                e -> e.requestSubFlow(
                    sf -> sf.handle(
                        WebFlux.outboundGateway("http://localhost:8080/mix-entry/name/{mixEntryName}", webClient)
                            .httpMethod(HttpMethod.GET)
                            .uriVariable("mixEntryName", "payload")
                            .expectedResponseType(String.class)
                        )
                    )
                    .headerExpression("mix-entry-id", "#jsonPath(payload, '$.id')")
            )
            .logAndReply();
}

当我使用不匹配的名称执行此操作时,我希望得到一个 HTTP/404,我得到的结果没有意义:

java.lang.IllegalStateException: Failed to execute CommandLineRunner
        at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:794) ~[spring-boot-2.5.2.jar:2.5.2]        
        at org.springframework.boot.SpringApplication.callRunners(SpringApplication.java:775) ~[spring-boot-2.5.2.jar:2.5.2]       
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:345) ~[spring-boot-2.5.2.jar:2.5.2]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1343) ~[spring-boot-2.5.2.jar:2.5.2]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1332) ~[spring-boot-2.5.2.jar:2.5.2]
        at com.oneangrybean.proto.mixintegration.MixIntegrationApplication.main(MixIntegrationApplication.java:20) ~[main/:na]     
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:na]
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]       
        at java.base/java.lang.reflect.Method.invoke(Method.java:566) ~[na:na]
        at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49) ~[spring-boot-devtools-2.5.2.jar:2.5.2]
Caused by: org.springframework.messaging.MessageHandlingException: nested exception is org.springframework.messaging.MessageHandlingException: nested exception is java.lang.IndexOutOfBoundsException: writerIndex(1671) + minWritableBytes(6521) exceeds maxCapacity(1671): PooledSlicedByteBuf(ridx: 0, widx: 1671, cap: 1671/1671, unwrapped: PooledUnsafeDirectByteBuf(ridx: 2048, widx: 2048, cap: 
2048)), failedMessage=GenericMessage [payload=Two, headers={replyChannel=org.springframework.messaging.core.GenericMessagingTemplate$TemporaryReplyChannel@84c674d, errorChannel=org.springframework.messaging.core.GenericMessagingTemplate$TemporaryReplyChannel@84c674d, id=1d634066-6d41-961a-9909-e6b23200b8b7, timestamp=1627760756046}]
        at org.springframework.integration.gateway.MessagingGatewaySupport.handleSendAndReceiveError(MessagingGatewaySupport.java:577) ~[spring-integration-core-5.5.1.jar:5.5.1]
        at org.springframework.integration.gateway.MessagingGatewaySupport.doSendAndReceive(MessagingGatewaySupport.java:546) ~[spring-integration-core-5.5.1.jar:5.5.1]
        at org.springframework.integration.gateway.MessagingGatewaySupport.sendAndReceiveMessage(MessagingGatewaySupport.java:491) 
~[spring-integration-core-5.5.1.jar:5.5.1]
        at org.springframework.integration.transformer.ContentEnricher$Gateway.sendAndReceiveMessage(ContentEnricher.java:497) ~[spring-integration-core-5.5.1.jar:5.5.1]
        at org.springframework.integration.transformer.ContentEnricher.handleRequestMessage(ContentEnricher.java:350) ~[spring-integration-core-5.5.1.jar:5.5.1]
        at org.springframework.integration.handler.AbstractReplyProducingMessageHandler.handleMessageInternal(AbstractReplyProducingMessageHandler.java:134) ~[spring-integration-core-5.5.1.jar:5.5.1]
        at org.springframework.integration.handler.AbstractMessageHandler.handleMessage(AbstractMessageHandler.java:56) ~[spring-integration-core-5.5.1.jar:5.5.1]
        at org.springframework.integration.dispatcher.AbstractDispatcher.tryOptimizedDispatch(AbstractDispatcher.java:115) ~[spring-integration-core-5.5.1.jar:5.5.1]
        at org.springframework.integration.dispatcher.UnicastingDispatcher.doDispatch(UnicastingDispatcher.java:133) ~[spring-integration-core-5.5.1.jar:5.5.1]
        at org.springframework.integration.dispatcher.UnicastingDispatcher.dispatch(UnicastingDispatcher.java:106) ~[spring-integration-core-5.5.1.jar:5.5.1]
        at org.springframework.integration.channel.AbstractSubscribableChannel.doSend(AbstractSubscribableChannel.java:72) ~[spring-integration-core-5.5.1.jar:5.5.1]
        at org.springframework.integration.channel.AbstractMessageChannel.send(AbstractMessageChannel.java:317) ~[spring-integration-core-5.5.1.jar:5.5.1]
        at org.springframework.integration.channel.AbstractMessageChannel.send(AbstractMessageChannel.java:272) ~[spring-integration-core-5.5.1.jar:5.5.1]
        at org.springframework.messaging.core.GenericMessagingTemplate.doSend(GenericMessagingTemplate.java:187) ~[spring-messaging-5.3.8.jar:5.3.8]
        at org.springframework.messaging.core.GenericMessagingTemplate.doSendAndReceive(GenericMessagingTemplate.java:233) ~[spring-messaging-5.3.8.jar:5.3.8]
        at org.springframework.messaging.core.GenericMessagingTemplate.doSendAndReceive(GenericMessagingTemplate.java:47) ~[spring-messaging-5.3.8.jar:5.3.8]
        at org.springframework.messaging.core.AbstractMessagingTemplate.sendAndReceive(AbstractMessagingTemplate.java:46) ~[spring-messaging-5.3.8.jar:5.3.8]
        at org.springframework.integration.core.MessagingTemplate.sendAndReceive(MessagingTemplate.java:97) ~[spring-integration-core-5.5.1.jar:5.5.1]
        at org.springframework.integration.core.MessagingTemplate.sendAndReceive(MessagingTemplate.java:38) ~[spring-integration-core-5.5.1.jar:5.5.1]
        at org.springframework.messaging.core.AbstractMessagingTemplate.convertSendAndReceive(AbstractMessagingTemplate.java:96) ~[spring-messaging-5.3.8.jar:5.3.8]
        at org.springframework.messaging.core.AbstractMessagingTemplate.convertSendAndReceive(AbstractMessagingTemplate.java:70) ~[spring-messaging-5.3.8.jar:5.3.8]
        at org.springframework.messaging.core.AbstractMessagingTemplate.convertSendAndReceive(AbstractMessagingTemplate.java:62) ~[spring-messaging-5.3.8.jar:5.3.8]
        at org.springframework.messaging.core.AbstractDestinationResolvingMessagingTemplate.convertSendAndReceive(AbstractDestinationResolvingMessagingTemplate.java:129) ~[spring-messaging-5.3.8.jar:5.3.8]
        at com.oneangrybean.proto.mixintegration.MixIntegrationApplication.lambda(MixIntegrationApplication.java:71) ~[main/:na] 
        at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:791) ~[spring-boot-2.5.2.jar:2.5.2]        
        ... 10 common frames omitted
Caused by: org.springframework.messaging.MessageHandlingException: nested exception is java.lang.IndexOutOfBoundsException: writerIndex(1671) + minWritableBytes(6521) exceeds maxCapacity(1671): PooledSlicedByteBuf(ridx: 0, widx: 1671, cap: 1671/1671, unwrapped: 
PooledUnsafeDirectByteBuf(ridx: 2048, widx: 2048, cap: 2048))
        at org.springframework.integration.handler.AbstractMessageProducingHandler.sendErrorMessage(AbstractMessageProducingHandler.java:485) ~[spring-integration-core-5.5.1.jar:5.5.1]
        at org.springframework.integration.handler.AbstractMessageProducingHandler$ReplyFutureCallback.onFailure(AbstractMessageProducingHandler.java:552) ~[spring-integration-core-5.5.1.jar:5.5.1]
        at org.springframework.util.concurrent.ListenableFutureCallbackRegistry.notifyFailure(ListenableFutureCallbackRegistry.java:86) ~[spring-core-5.3.8.jar:5.3.8]
        at org.springframework.util.concurrent.ListenableFutureCallbackRegistry.failure(ListenableFutureCallbackRegistry.java:158) 
~[spring-core-5.3.8.jar:5.3.8]
        at org.springframework.util.concurrent.ListenableFutureTask.done(ListenableFutureTask.java:100) ~[spring-core-5.3.8.jar:5.3.8]
        at org.springframework.util.concurrent.SettableListenableFuture$SettableTask.done(SettableListenableFuture.java:175) ~[spring-core-5.3.8.jar:5.3.8]
        at java.base/java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:381) ~[na:na]
        at java.base/java.util.concurrent.FutureTask.setException(FutureTask.java:250) ~[na:na]
        at org.springframework.util.concurrent.SettableListenableFuture$SettableTask.setExceptionResult(SettableListenableFuture.java:163) ~[spring-core-5.3.8.jar:5.3.8]
        at org.springframework.util.concurrent.SettableListenableFuture.setException(SettableListenableFuture.java:70) ~[spring-core-5.3.8.jar:5.3.8]
        at reactor.core.publisher.LambdaMonoSubscriber.doError(LambdaMonoSubscriber.java:155) ~[reactor-core-3.4.7.jar:3.4.7]      
        at reactor.core.publisher.LambdaMonoSubscriber.onError(LambdaMonoSubscriber.java:150) ~[reactor-core-3.4.7.jar:3.4.7]      
        at reactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber.onError(FluxMapFuseable.java:140) ~[reactor-core-3.4.7.jar:3.4.7]
        at reactor.core.publisher.MonoFlatMap$FlatMapMain.onError(MonoFlatMap.java:172) ~[reactor-core-3.4.7.jar:3.4.7]
        at reactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber.onError(FluxMapFuseable.java:140) ~[reactor-core-3.4.7.jar:3.4.7]
        at reactor.core.publisher.MonoFlatMap$FlatMapMain.secondError(MonoFlatMap.java:192) ~[reactor-core-3.4.7.jar:3.4.7]        
        at reactor.core.publisher.MonoFlatMap$FlatMapInner.onError(MonoFlatMap.java:259) ~[reactor-core-3.4.7.jar:3.4.7]
        at reactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber.onError(FluxMapFuseable.java:140) ~[reactor-core-3.4.7.jar:3.4.7]
        at reactor.core.publisher.MonoCollectList$MonoCollectListSubscriber.onError(MonoCollectList.java:113) ~[reactor-core-3.4.7.jar:3.4.7]
        at reactor.core.publisher.Operators$MultiSubscriptionSubscriber.onError(Operators.java:2062) ~[reactor-core-3.4.7.jar:3.4.7]
        at reactor.core.publisher.FluxOnAssembly$OnAssemblySubscriber.onError(FluxOnAssembly.java:392) ~[reactor-core-3.4.7.jar:3.4.7]
        at reactor.core.publisher.MonoFlatMap$FlatMapMain.onError(MonoFlatMap.java:172) ~[reactor-core-3.4.7.jar:3.4.7]
        at reactor.core.publisher.FluxOnErrorResume$ResumeSubscriber.onError(FluxOnErrorResume.java:106) ~[reactor-core-3.4.7.jar:3.4.7]
        at reactor.core.publisher.MonoIgnoreThen$ThenIgnoreMain.onError(MonoIgnoreThen.java:270) ~[reactor-core-3.4.7.jar:3.4.7]   
        at reactor.core.publisher.MonoIgnoreThen$ThenIgnoreMain.subscribeNext(MonoIgnoreThen.java:227) ~[reactor-core-3.4.7.jar:3.4.7]
        at reactor.core.publisher.MonoIgnoreThen$ThenIgnoreMain.onComplete(MonoIgnoreThen.java:203) ~[reactor-core-3.4.7.jar:3.4.7]        at reactor.core.publisher.Operators$MultiSubscriptionSubscriber.onComplete(Operators.java:2057) ~[reactor-core-3.4.7.jar:3.4.7]
        at reactor.core.publisher.Operators.complete(Operators.java:136) ~[reactor-core-3.4.7.jar:3.4.7]
        at reactor.core.publisher.MonoEmpty.subscribe(MonoEmpty.java:45) ~[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.FluxOnErrorResume$ResumeSubscriber.onError(FluxOnErrorResume.java:103) ~[reactor-core-3.4.7.jar:3.4.7]
        at reactor.core.publisher.MonoIgnoreElements$IgnoreElementsSubscriber.onError(MonoIgnoreElements.java:83) ~[reactor-core-3.4.7.jar:3.4.7]
        at reactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber.onError(FluxMapFuseable.java:140) ~[reactor-core-3.4.7.jar:3.4.7]
        at reactor.core.publisher.FluxOnAssembly$OnAssemblySubscriber.onError(FluxOnAssembly.java:392) ~[reactor-core-3.4.7.jar:3.4.7]
        at reactor.core.publisher.FluxMap$MapSubscriber.onError(FluxMap.java:132) ~[reactor-core-3.4.7.jar:3.4.7]
        at reactor.core.publisher.FluxPeek$PeekSubscriber.onError(FluxPeek.java:221) ~[reactor-core-3.4.7.jar:3.4.7]
        at reactor.core.publisher.FluxMap$MapSubscriber.onError(FluxMap.java:132) ~[reactor-core-3.4.7.jar:3.4.7]
        at reactor.core.publisher.Operators.error(Operators.java:197) ~[reactor-core-3.4.7.jar:3.4.7]
        at reactor.netty.channel.FluxReceive.startReceiver(FluxReceive.java:183) ~[reactor-netty-core-1.0.8.jar:1.0.8]
        at reactor.netty.channel.FluxReceive.subscribe(FluxReceive.java:144) ~[reactor-netty-core-1.0.8.jar:1.0.8]
        at reactor.core.publisher.InternalFluxOperator.subscribe(InternalFluxOperator.java:62) ~[reactor-core-3.4.7.jar:3.4.7]     
        at reactor.netty.ByteBufFlux.subscribe(ByteBufFlux.java:340) ~[reactor-netty-core-1.0.8.jar:1.0.8]
        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.Mono.subscribe(Mono.java:4150) ~[reactor-core-3.4.7.jar:3.4.7]
        at reactor.core.publisher.FluxOnErrorResume$ResumeSubscriber.onError(FluxOnErrorResume.java:103) ~[reactor-core-3.4.7.jar:3.4.7]
        at reactor.core.publisher.MonoFlatMap$FlatMapMain.onError(MonoFlatMap.java:172) ~[reactor-core-3.4.7.jar:3.4.7]
        at reactor.core.publisher.FluxMap$MapSubscriber.onError(FluxMap.java:132) ~[reactor-core-3.4.7.jar:3.4.7]
        at reactor.core.publisher.Operators$MonoSubscriber.onError(Operators.java:1862) ~[reactor-core-3.4.7.jar:3.4.7]
        at reactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber.onError(FluxMapFuseable.java:140) ~[reactor-core-3.4.7.jar:3.4.7]
        at reactor.core.publisher.MonoReduce$ReduceSubscriber.onNext(MonoReduce.java:110) ~[reactor-core-3.4.7.jar:3.4.7]
        at reactor.core.publisher.FluxOnAssembly$OnAssemblySubscriber.onNext(FluxOnAssembly.java:387) ~[reactor-core-3.4.7.jar:3.4.7]
        at reactor.core.publisher.FluxMap$MapSubscriber.onNext(FluxMap.java:120) ~[reactor-core-3.4.7.jar:3.4.7]
        at reactor.core.publisher.FluxPeek$PeekSubscriber.onNext(FluxPeek.java:199) ~[reactor-core-3.4.7.jar:3.4.7]
        at reactor.core.publisher.FluxMap$MapSubscriber.onNext(FluxMap.java:120) ~[reactor-core-3.4.7.jar:3.4.7]
        at reactor.netty.channel.FluxReceive.onInboundNext(FluxReceive.java:365) ~[reactor-netty-core-1.0.8.jar:1.0.8]
        at reactor.netty.channel.ChannelOperations.onInboundNext(ChannelOperations.java:405) ~[reactor-netty-core-1.0.8.jar:1.0.8] 
        at reactor.netty.http.client.HttpClientOperations.onInboundNext(HttpClientOperations.java:707) ~[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 io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:103) ~[netty-codec-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.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.fireChannelRead(ByteToMessageDecoder.java:311) ~[netty-codec-4.1.65.Final.jar:4.1.65.Final]
        at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:432) ~[netty-codec-4.1.65.Final.jar:4.1.65.Final]
        at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:276) ~[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.run(SingleThreadEventExecutor.java:989) ~[netty-common-4.1.65.Final.jar:4.1.65.Final]
        at io.netty.util.internal.ThreadExecutorMap.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:829) ~[na:na]
Caused by: java.lang.IndexOutOfBoundsException: writerIndex(1671) + minWritableBytes(6521) exceeds maxCapacity(1671): PooledSlicedByteBuf(ridx: 0, widx: 1671, cap: 1671/1671, unwrapped: PooledUnsafeDirectByteBuf(ridx: 2048, widx: 2048, cap: 2048))
        at io.netty.buffer.AbstractByteBuf.ensureWritable0(AbstractByteBuf.java:294) ~[netty-buffer-4.1.65.Final.jar:4.1.65.Final] 
        Suppressed: reactor.core.publisher.FluxOnAssembly$OnAssemblyException:
Error has been observed at the following site(s):
        |_ checkpoint ⇢ 404 from GET http://localhost:8080/mix-entry/name/Two [DefaultWebClient]
Stack trace:
                at io.netty.buffer.AbstractByteBuf.ensureWritable0(AbstractByteBuf.java:294) ~[netty-buffer-4.1.65.Final.jar:4.1.65.Final]
                at io.netty.buffer.AbstractByteBuf.ensureWritable(AbstractByteBuf.java:280) ~[netty-buffer-4.1.65.Final.jar:4.1.65.Final]
                at io.netty.buffer.AbstractByteBuf.writeBytes(AbstractByteBuf.java:1103) ~[netty-buffer-4.1.65.Final.jar:4.1.65.Final]
                at io.netty.buffer.AbstractByteBuf.writeBytes(AbstractByteBuf.java:1096) ~[netty-buffer-4.1.65.Final.jar:4.1.65.Final]
                at io.netty.buffer.AbstractByteBuf.writeBytes(AbstractByteBuf.java:1087) ~[netty-buffer-4.1.65.Final.jar:4.1.65.Final]
                at org.springframework.core.io.buffer.NettyDataBuffer.write(NettyDataBuffer.java:237) ~[spring-core-5.3.8.jar:5.3.8]
                at org.springframework.core.io.buffer.NettyDataBuffer.write(NettyDataBuffer.java:195) ~[spring-core-5.3.8.jar:5.3.8]
                at org.springframework.core.io.buffer.NettyDataBuffer.write(NettyDataBuffer.java:43) ~[spring-core-5.3.8.jar:5.3.8]                at org.springframework.integration.webflux.outbound.WebFluxRequestExecutingMessageHandler.lambda$exchangeForResponseMono(WebFluxRequestExecutingMessageHandler.java:305) ~[spring-integration-webflux-5.5.1.jar:5.5.1]
                at reactor.core.publisher.MonoReduce$ReduceSubscriber.onNext(MonoReduce.java:101) ~[reactor-core-3.4.7.jar:3.4.7]  
                at reactor.core.publisher.FluxMap$MapSubscriber.onNext(FluxMap.java:120) ~[reactor-core-3.4.7.jar:3.4.7]
                at reactor.core.publisher.FluxPeek$PeekSubscriber.onNext(FluxPeek.java:199) ~[reactor-core-3.4.7.jar:3.4.7]        
                at reactor.core.publisher.FluxMap$MapSubscriber.onNext(FluxMap.java:120) ~[reactor-core-3.4.7.jar:3.4.7]
                at reactor.netty.channel.FluxReceive.onInboundNext(FluxReceive.java:365) ~[reactor-netty-core-1.0.8.jar:1.0.8]     
                at reactor.netty.channel.ChannelOperations.onInboundNext(ChannelOperations.java:405) ~[reactor-netty-core-1.0.8.jar:1.0.8]
                at reactor.netty.http.client.HttpClientOperations.onInboundNext(HttpClientOperations.java:707) ~[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 io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:103) ~[netty-codec-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.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.fireChannelRead(ByteToMessageDecoder.java:311) ~[netty-codec-4.1.65.Final.jar:4.1.65.Final]
                at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:432) ~[netty-codec-4.1.65.Final.jar:4.1.65.Final]
                at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:276) ~[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.run(SingleThreadEventExecutor.java:989) ~[netty-common-4.1.65.Final.jar:4.1.65.Final]
                at io.netty.util.internal.ThreadExecutorMap.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:829) ~[na:na]

我看到 HTTP/404 检查点,但看起来代码无法写入 HTTP/404 的响应内容,因为它超出了缓冲区。

我在 gitter 网站上提出了这个问题 - Artem Bilan 表示这可能是 Netty 的一个问题而不是 Spring-Integration。

我的目的是达到这样一个程度,即如果有 HTTP/404,我可以优雅地处理它,并且 return 默认响应文档 { "id": -1, "name": null }.

如有任何想法,我们将不胜感激。

OP 注意:此更改已与 Spring 集成版本 5.3.9.RELEASE5.4.105.5.3 集成。

@artem-bilan 帮助确定了这个问题。 spring-integration#3610

已解决此问题