2022-03-03 22:10:19.531  WARN [client-side-report-gw,372b15526d269590,372b15526d269590,true] 1 --- [or-http-epoll-1] c.d.c.filter.RemoteGeoFilter             : fail to query geo info from ip 172.16.0.237: The address 172.16.0.237 is not in the database.
2022-03-03 22:10:19.533 ERROR [client-side-report-gw,372b15526d269590,372b15526d269590,true] 1 --- [llEventLoop-5-1] a.w.r.e.AbstractErrorWebExceptionHandler : [b36a3995-7829140]  500 Server Error for HTTP GET "/"

java.lang.IllegalArgumentException: a header value must not end with '\r' or '\n':uid=0(root) gid=0(root) groups=0(root)

    at io.netty.handler.codec.http.DefaultHttpHeaders$HeaderValueConverterAndValidator.convertObject(DefaultHttpHeaders.java:457) ~[netty-codec-http-4.1.52.Final.jar!/:4.1.52.Final]
    Suppressed: reactor.core.publisher.FluxOnAssembly$OnAssemblyException: 
Error has been observed at the following site(s):
    |_ checkpoint ⇢ org.springframework.web.cors.reactive.CorsWebFilter [DefaultWebFilterChain]
    |_ checkpoint ⇢ org.springframework.cloud.gateway.filter.WeightCalculatorWebFilter [DefaultWebFilterChain]
    |_ checkpoint ⇢ org.springframework.cloud.sleuth.instrument.web.TraceWebFilter [DefaultWebFilterChain]
    |_ checkpoint ⇢ org.springframework.boot.actuate.metrics.web.reactive.server.MetricsWebFilter [DefaultWebFilterChain]
    |_ checkpoint ⇢ HTTP GET "/" [ExceptionHandlingWebHandler]
Stack trace:
        at io.netty.handler.codec.http.DefaultHttpHeaders$HeaderValueConverterAndValidator.convertObject(DefaultHttpHeaders.java:457) ~[netty-codec-http-4.1.52.Final.jar!/:4.1.52.Final]
        at io.netty.handler.codec.http.DefaultHttpHeaders$HeaderValueConverterAndValidator.convertObject(DefaultHttpHeaders.java:444) ~[netty-codec-http-4.1.52.Final.jar!/:4.1.52.Final]
        at io.netty.handler.codec.DefaultHeaders.addObject(DefaultHeaders.java:327) ~[netty-codec-4.1.52.Final.jar!/:4.1.52.Final]
        at io.netty.handler.codec.http.DefaultHttpHeaders.add(DefaultHttpHeaders.java:129) ~[netty-codec-http-4.1.52.Final.jar!/:4.1.52.Final]
        at org.springframework.http.server.reactive.NettyHeadersAdapter.add(NettyHeadersAdapter.java:57) ~[spring-web-5.2.9.RELEASE.jar!/:5.2.9.RELEASE]
        at org.springframework.http.server.reactive.NettyHeadersAdapter.add(NettyHeadersAdapter.java:39) ~[spring-web-5.2.9.RELEASE.jar!/:5.2.9.RELEASE]
        at org.springframework.http.HttpHeaders.add(HttpHeaders.java:1642) ~[spring-web-5.2.9.RELEASE.jar!/:5.2.9.RELEASE]
        at org.springframework.cloud.gateway.filter.factory.AddResponseHeaderGatewayFilterFactory$1.filter(AddResponseHeaderGatewayFilterFactory.java:41) ~[spring-cloud-gateway-core-2.2.5.RELEASE.jar!/:2.2.5.RELEASE]
        at org.springframework.cloud.gateway.filter.OrderedGatewayFilter.filter(OrderedGatewayFilter.java:44) ~[spring-cloud-gateway-core-2.2.5.RELEASE.jar!/:2.2.5.RELEASE]
        at org.springframework.cloud.gateway.handler.FilteringWebHandler$DefaultGatewayFilterChain.lambda$filter$0(FilteringWebHandler.java:118) ~[spring-cloud-gateway-core-2.2.5.RELEASE.jar!/:2.2.5.RELEASE]
        at reactor.core.publisher.MonoDefer.subscribe(MonoDefer.java:44) ~[reactor-core-3.3.10.RELEASE.jar!/:3.3.10.RELEASE]
        at reactor.core.publisher.InternalMonoOperator.subscribe(InternalMonoOperator.java:64) ~[reactor-core-3.3.10.RELEASE.jar!/:3.3.10.RELEASE]
        at reactor.core.publisher.MonoFlatMap$FlatMapMain.onNext(MonoFlatMap.java:150) ~[reactor-core-3.3.10.RELEASE.jar!/:3.3.10.RELEASE]
        at org.springframework.cloud.sleuth.instrument.reactor.ScopePassingSpanSubscriber.onNext(ScopePassingSpanSubscriber.java:90) ~[spring-cloud-sleuth-core-2.2.5.RELEASE.jar!/:2.2.5.RELEASE]
        at reactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber.onNext(FluxMapFuseable.java:121) ~[reactor-core-3.3.10.RELEASE.jar!/:3.3.10.RELEASE]
        at org.springframework.cloud.sleuth.instrument.reactor.ScopePassingSpanSubscriber.onNext(ScopePassingSpanSubscriber.java:90) ~[spring-cloud-sleuth-core-2.2.5.RELEASE.jar!/:2.2.5.RELEASE]
        at reactor.core.publisher.Operators$MonoSubscriber.complete(Operators.java:1782) ~[reactor-core-3.3.10.RELEASE.jar!/:3.3.10.RELEASE]
        at reactor.core.publisher.MonoReduceSeed$ReduceSeedSubscriber.onComplete(MonoReduceSeed.java:148) ~[reactor-core-3.3.10.RELEASE.jar!/:3.3.10.RELEASE]
        at org.springframework.cloud.sleuth.instrument.reactor.ScopePassingSpanSubscriber.onComplete(ScopePassingSpanSubscriber.java:104) ~[spring-cloud-sleuth-core-2.2.5.RELEASE.jar!/:2.2.5.RELEASE]
        at reactor.core.publisher.Operators$MultiSubscriptionSubscriber.onComplete(Operators.java:2016) ~[reactor-core-3.3.10.RELEASE.jar!/:3.3.10.RELEASE]
        at org.springframework.cloud.sleuth.instrument.reactor.ScopePassingSpanSubscriber.onComplete(ScopePassingSpanSubscriber.java:104) ~[spring-cloud-sleuth-core-2.2.5.RELEASE.jar!/:2.2.5.RELEASE]
        at reactor.core.publisher.FluxUsingWhen$UsingWhenSubscriber.deferredComplete(FluxUsingWhen.java:402) ~[reactor-core-3.3.10.RELEASE.jar!/:3.3.10.RELEASE]
        at reactor.core.publisher.FluxUsingWhen$CommitInner.onComplete(FluxUsingWhen.java:536) ~[reactor-core-3.3.10.RELEASE.jar!/:3.3.10.RELEASE]
        at org.springframework.cloud.sleuth.instrument.reactor.ScopePassingSpanSubscriber.onComplete(ScopePassingSpanSubscriber.java:104) ~[spring-cloud-sleuth-core-2.2.5.RELEASE.jar!/:2.2.5.RELEASE]
        at reactor.core.publisher.MonoIgnoreElements$IgnoreElementsSubscriber.onComplete(MonoIgnoreElements.java:81) ~[reactor-core-3.3.10.RELEASE.jar!/:3.3.10.RELEASE]
        at org.springframework.cloud.sleuth.instrument.reactor.ScopePassingSpanSubscriber.onComplete(ScopePassingSpanSubscriber.java:104) ~[spring-cloud-sleuth-core-2.2.5.RELEASE.jar!/:2.2.5.RELEASE]
        at reactor.core.publisher.FluxFlatMap$FlatMapMain.checkTerminated(FluxFlatMap.java:816) ~[reactor-core-3.3.10.RELEASE.jar!/:3.3.10.RELEASE]
        at reactor.core.publisher.FluxFlatMap$FlatMapMain.drainLoop(FluxFlatMap.java:600) ~[reactor-core-3.3.10.RELEASE.jar!/:3.3.10.RELEASE]
        at reactor.core.publisher.FluxFlatMap$FlatMapMain.drain(FluxFlatMap.java:580) ~[reactor-core-3.3.10.RELEASE.jar!/:3.3.10.RELEASE]
        at reactor.core.publisher.FluxFlatMap$FlatMapMain.onComplete(FluxFlatMap.java:457) ~[reactor-core-3.3.10.RELEASE.jar!/:3.3.10.RELEASE]
        at reactor.core.publisher.FluxArray$ArraySubscription.slowPath(FluxArray.java:137) ~[reactor-core-3.3.10.RELEASE.jar!/:3.3.10.RELEASE]
        at reactor.core.publisher.FluxArray$ArraySubscription.request(FluxArray.java:99) ~[reactor-core-3.3.10.RELEASE.jar!/:3.3.10.RELEASE]
        at reactor.core.publisher.FluxFlatMap$FlatMapMain.onSubscribe(FluxFlatMap.java:363) ~[reactor-core-3.3.10.RELEASE.jar!/:3.3.10.RELEASE]
        at reactor.core.publisher.FluxMerge.subscribe(FluxMerge.java:69) ~[reactor-core-3.3.10.RELEASE.jar!/:3.3.10.RELEASE]
        at reactor.core.publisher.Mono.subscribe(Mono.java:4213) ~[reactor-core-3.3.10.RELEASE.jar!/:3.3.10.RELEASE]
        at reactor.core.publisher.FluxUsingWhen$UsingWhenSubscriber.onComplete(FluxUsingWhen.java:394) ~[reactor-core-3.3.10.RELEASE.jar!/:3.3.10.RELEASE]
        at org.springframework.cloud.sleuth.instrument.reactor.ScopePassingSpanSubscriber.onComplete(ScopePassingSpanSubscriber.java:104) ~[spring-cloud-sleuth-core-2.2.5.RELEASE.jar!/:2.2.5.RELEASE]
        at reactor.core.publisher.FluxMap$MapSubscriber.onComplete(FluxMap.java:136) ~[reactor-core-3.3.10.RELEASE.jar!/:3.3.10.RELEASE]
        at org.springframework.cloud.sleuth.instrument.reactor.ScopePassingSpanSubscriber.onComplete(ScopePassingSpanSubscriber.java:104) ~[spring-cloud-sleuth-core-2.2.5.RELEASE.jar!/:2.2.5.RELEASE]
        at reactor.core.publisher.Operators$MultiSubscriptionSubscriber.onComplete(Operators.java:2016) ~[reactor-core-3.3.10.RELEASE.jar!/:3.3.10.RELEASE]
        at org.springframework.cloud.sleuth.instrument.reactor.ScopePassingSpanSubscriber.onComplete(ScopePassingSpanSubscriber.java:104) ~[spring-cloud-sleuth-core-2.2.5.RELEASE.jar!/:2.2.5.RELEASE]
        at reactor.core.publisher.FluxConcatMap$ConcatMapImmediate.drain(FluxConcatMap.java:359) ~[reactor-core-3.3.10.RELEASE.jar!/:3.3.10.RELEASE]
        at reactor.core.publisher.FluxConcatMap$ConcatMapImmediate.onComplete(FluxConcatMap.java:268) ~[reactor-core-3.3.10.RELEASE.jar!/:3.3.10.RELEASE]
        at org.springframework.cloud.sleuth.instrument.reactor.ScopePassingSpanSubscriber.onComplete(ScopePassingSpanSubscriber.java:104) ~[spring-cloud-sleuth-core-2.2.5.RELEASE.jar!/:2.2.5.RELEASE]
        at reactor.core.publisher.Operators$MultiSubscriptionSubscriber.onComplete(Operators.java:2016) ~[reactor-core-3.3.10.RELEASE.jar!/:3.3.10.RELEASE]
        at org.springframework.cloud.sleuth.instrument.reactor.ScopePassingSpanSubscriber.onComplete(ScopePassingSpanSubscriber.java:104) ~[spring-cloud-sleuth-core-2.2.5.RELEASE.jar!/:2.2.5.RELEASE]
        at reactor.core.publisher.MonoFlatMapMany$FlatMapManyInner.onComplete(MonoFlatMapMany.java:252) ~[reactor-core-3.3.10.RELEASE.jar!/:3.3.10.RELEASE]
        at org.springframework.cloud.sleuth.instrument.reactor.ScopePassingSpanSubscriber.onComplete(ScopePassingSpanSubscriber.java:104) ~[spring-cloud-sleuth-core-2.2.5.RELEASE.jar!/:2.2.5.RELEASE]
        at reactor.core.publisher.MonoFlatMapMany$FlatMapManyInner.onComplete(MonoFlatMapMany.java:252) ~[reactor-core-3.3.10.RELEASE.jar!/:3.3.10.RELEASE]
        at org.springframework.cloud.sleuth.instrument.reactor.ScopePassingSpanSubscriber.onComplete(ScopePassingSpanSubscriber.java:104) ~[spring-cloud-sleuth-core-2.2.5.RELEASE.jar!/:2.2.5.RELEASE]
        at io.lettuce.core.RedisPublisher$ImmediateSubscriber.onComplete(RedisPublisher.java:927) ~[lettuce-core-5.3.4.RELEASE.jar!/:5.3.4.RELEASE]
        at io.lettuce.core.RedisPublisher$State.onAllDataRead(RedisPublisher.java:697) ~[lettuce-core-5.3.4.RELEASE.jar!/:5.3.4.RELEASE]
        at io.lettuce.core.RedisPublisher$State$3.read(RedisPublisher.java:607) ~[lettuce-core-5.3.4.RELEASE.jar!/:5.3.4.RELEASE]
        at io.lettuce.core.RedisPublisher$State$3.onDataAvailable(RedisPublisher.java:564) ~[lettuce-core-5.3.4.RELEASE.jar!/:5.3.4.RELEASE]
        at io.lettuce.core.RedisPublisher$RedisSubscription.onDataAvailable(RedisPublisher.java:325) ~[lettuce-core-5.3.4.RELEASE.jar!/:5.3.4.RELEASE]
        at io.lettuce.core.RedisPublisher$RedisSubscription.onAllDataRead(RedisPublisher.java:340) ~[lettuce-core-5.3.4.RELEASE.jar!/:5.3.4.RELEASE]
        at io.lettuce.core.RedisPublisher$SubscriptionCommand.complete(RedisPublisher.java:786) ~[lettuce-core-5.3.4.RELEASE.jar!/:5.3.4.RELEASE]
        at io.lettuce.core.protocol.CommandWrapper.complete(CommandWrapper.java:59) ~[lettuce-core-5.3.4.RELEASE.jar!/:5.3.4.RELEASE]
        at io.lettuce.core.protocol.CommandHandler.complete(CommandHandler.java:680) ~[lettuce-core-5.3.4.RELEASE.jar!/:5.3.4.RELEASE]
        at io.lettuce.core.protocol.CommandHandler.decode(CommandHandler.java:640) ~[lettuce-core-5.3.4.RELEASE.jar!/:5.3.4.RELEASE]
        at io.lettuce.core.protocol.CommandHandler.channelRead(CommandHandler.java:591) ~[lettuce-core-5.3.4.RELEASE.jar!/:5.3.4.RELEASE]
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) ~[netty-transport-4.1.52.Final.jar!/:4.1.52.Final]
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) ~[netty-transport-4.1.52.Final.jar!/:4.1.52.Final]
        at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357) ~[netty-transport-4.1.52.Final.jar!/:4.1.52.Final]
        at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1410) ~[netty-transport-4.1.52.Final.jar!/:4.1.52.Final]
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) ~[netty-transport-4.1.52.Final.jar!/:4.1.52.Final]
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) ~[netty-transport-4.1.52.Final.jar!/:4.1.52.Final]
        at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:919) ~[netty-transport-4.1.52.Final.jar!/:4.1.52.Final]
        at io.netty.channel.epoll.AbstractEpollStreamChannel$EpollStreamUnsafe.epollInReady(AbstractEpollStreamChannel.java:795) ~[netty-transport-native-epoll-4.1.52.Final-linux-x86_64.jar!/:4.1.52.Final]
        at io.netty.channel.epoll.EpollEventLoop.processReady(EpollEventLoop.java:475) ~[netty-transport-native-epoll-4.1.52.Final-linux-x86_64.jar!/:4.1.52.Final]
        at io.netty.channel.epoll.EpollEventLoop.run(EpollEventLoop.java:378) ~[netty-transport-native-epoll-4.1.52.Final-linux-x86_64.jar!/:4.1.52.Final]
        at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989) ~[netty-common-4.1.52.Final.jar!/:4.1.52.Final]
        at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) ~[netty-common-4.1.52.Final.jar!/:4.1.52.Final]
        at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) ~[netty-common-4.1.52.Final.jar!/:4.1.52.Final]
        at java.lang.Thread.run(Thread.java:748) ~[na:1.8.0_241]

日志贴了一大堆,其实核心的信息只有一条:

a header value must not end with '\r' or '\n' 

这个的意思是,header的value值不能以'r' 或者 'n' 结束。发生的场景是:内网提交数据的时候,在构造header的时候含有一些以'r' 或者 'n' 结尾的数据。

解决办法:replace函数过滤掉:'r' 和 'n' 字符。

拓展:为何不能以以'r' 或者 'n' 结尾?

原因在http的协议决定,详细可以了解rfc 文档。笔者认为,http协议中,每一个模块的结束都是以rn 作为协议区分,所以header再以这两个关键字作为结尾,就会和rfc原有的定义相冲突。