spring-cloud / spring-cloud-gateway

An API Gateway built on Spring Framework and Spring Boot providing routing and more.
http://cloud.spring.io
Apache License 2.0
4.52k stars 3.32k forks source link

my gateway hava a bug java.lang.IndexOutOfBoundsException: Index: 0, Size: 0 #2542

Closed prefectchen closed 1 year ago

prefectchen commented 2 years ago

Describe the bug spring cloud version : Greenwich.SR3 gateway version : 2.1.3.RELEASE

this is a Weird bug ,my project start ok and test success, it is run some day , one day it is have this bug .

2022-03-06 13:01:11.396 [reactor-http-epoll-5] ERROR o.s.b.a.w.r.error.AbstractErrorWebExceptionHandler.error:122 - [956eb507] 500 Server Error for HTTP POST "/recharge/mobile/order"
java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
    at java.util.ArrayList.rangeCheck(ArrayList.java:659)
    at java.util.ArrayList.get(ArrayList.java:435)
    at org.springframework.cloud.gateway.route.RouteDefinitionRouteLocator.combinePredicates(RouteDefinitionRouteLocator.java:221)
    at org.springframework.cloud.gateway.route.RouteDefinitionRouteLocator.convertToRoute(RouteDefinitionRouteLocator.java:143)
    at reactor.core.publisher.FluxMap$MapSubscriber.onNext(FluxMap.java:100)
    at reactor.core.publisher.FluxFlatMap$FlatMapMain.drainLoop(FluxFlatMap.java:695)
    at reactor.core.publisher.FluxFlatMap$FlatMapMain.drain(FluxFlatMap.java:571)
    at reactor.core.publisher.FluxFlatMap$FlatMapInner.onSubscribe(FluxFlatMap.java:955)
    at reactor.core.publisher.FluxIterable.subscribe(FluxIterable.java:139)
    at reactor.core.publisher.FluxIterable.subscribe(FluxIterable.java:63)
    at reactor.core.publisher.Flux.subscribe(Flux.java:7923)
    at reactor.core.publisher.FluxFlatMap$FlatMapMain.onNext(FluxFlatMap.java:420)
    at reactor.core.publisher.FluxIterable$IterableSubscription.slowPath(FluxIterable.java:243)
    at reactor.core.publisher.FluxIterable$IterableSubscription.request(FluxIterable.java:201)
    at reactor.core.publisher.FluxFlatMap$FlatMapMain.onSubscribe(FluxFlatMap.java:366)
    at reactor.core.publisher.FluxIterable.subscribe(FluxIterable.java:139)
    at reactor.core.publisher.FluxIterable.subscribe(FluxIterable.java:63)
    at reactor.core.publisher.FluxFlatMap.subscribe(FluxFlatMap.java:97)
    at reactor.core.publisher.FluxMap.subscribe(FluxMap.java:62)
    at reactor.core.publisher.FluxMap.subscribe(FluxMap.java:62)
    at reactor.core.publisher.Flux.subscribe(Flux.java:7923)
    at reactor.core.publisher.FluxFlatMap$FlatMapMain.onNext(FluxFlatMap.java:420)
    at reactor.core.publisher.FluxIterable$IterableSubscription.slowPath(FluxIterable.java:243)
    at reactor.core.publisher.FluxIterable$IterableSubscription.request(FluxIterable.java:201)
    at reactor.core.publisher.FluxFlatMap$FlatMapMain.onSubscribe(FluxFlatMap.java:366)
    at reactor.core.publisher.FluxIterable.subscribe(FluxIterable.java:139)
    at reactor.core.publisher.FluxIterable.subscribe(FluxIterable.java:63)
    at reactor.core.publisher.FluxFlatMap.subscribe(FluxFlatMap.java:97)
    at reactor.core.publisher.MonoCollectList.subscribe(MonoCollectList.java:40)
    at reactor.core.publisher.MonoMapFuseable.subscribe(MonoMapFuseable.java:59)
    at reactor.core.publisher.MonoFlattenIterable.subscribe(MonoFlattenIterable.java:101)
    at reactor.core.publisher.FluxMaterialize.subscribe(FluxMaterialize.java:40)
    at reactor.core.publisher.MonoCollectList.subscribe(MonoCollectList.java:40)
    at reactor.core.publisher.MonoPeekFuseable.subscribe(MonoPeekFuseable.java:74)
    at reactor.core.publisher.MonoFlattenIterable.subscribe(MonoFlattenIterable.java:101)
    at reactor.core.publisher.FluxDematerialize.subscribe(FluxDematerialize.java:39)
    at reactor.core.publisher.FluxDefer.subscribe(FluxDefer.java:54)
    at reactor.core.publisher.Flux.subscribe(Flux.java:7923)
    at reactor.core.publisher.Flux.subscribeWith(Flux.java:8087)
    at reactor.core.publisher.Flux.subscribe(Flux.java:7916)
    at reactor.core.publisher.Flux.subscribe(Flux.java:7880)
    at reactor.core.publisher.Flux.subscribe(Flux.java:7798)
    at org.springframework.cloud.gateway.filter.WeightCalculatorWebFilter.lambda$onApplicationEvent$0(WeightCalculatorWebFilter.java:133)
    at org.springframework.beans.factory.ObjectProvider.ifAvailable(ObjectProvider.java:93)
    at org.springframework.cloud.gateway.filter.WeightCalculatorWebFilter.onApplicationEvent(WeightCalculatorWebFilter.java:133)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139)
    at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:402)
    at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:359)
    at org.springframework.cloud.gateway.actuate.AbstractGatewayControllerEndpoint.refresh(AbstractGatewayControllerEndpoint.java:85)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.springframework.web.reactive.result.method.InvocableHandlerMethod.lambda$invoke$0(InvocableHandlerMethod.java:137)
    at reactor.core.publisher.FluxFlatMap.trySubscribeScalarMap(FluxFlatMap.java:152)
    at reactor.core.publisher.MonoFlatMap.subscribe(MonoFlatMap.java:53)
    at reactor.core.publisher.MonoDefer.subscribe(MonoDefer.java:52)
    at reactor.core.publisher.MonoIgnoreThen$ThenIgnoreMain.drain(MonoIgnoreThen.java:153)
    at reactor.core.publisher.MonoIgnoreThen.subscribe(MonoIgnoreThen.java:56)
    at reactor.core.publisher.MonoPeekFuseable.subscribe(MonoPeekFuseable.java:74)
    at reactor.core.publisher.MonoPeekFuseable.subscribe(MonoPeekFuseable.java:74)
    at reactor.core.publisher.MonoOnErrorResume.subscribe(MonoOnErrorResume.java:44)
    at reactor.core.publisher.MonoFlatMap$FlatMapMain.onNext(MonoFlatMap.java:150)
    at reactor.core.publisher.FluxSwitchIfEmpty$SwitchIfEmptySubscriber.onNext(FluxSwitchIfEmpty.java:67)
    at reactor.core.publisher.MonoNext$NextSubscriber.onNext(MonoNext.java:76)
    at reactor.core.publisher.FluxConcatMap$ConcatMapImmediate.innerNext(FluxConcatMap.java:275)
    at reactor.core.publisher.FluxConcatMap$ConcatMapInner.onNext(FluxConcatMap.java:849)
    at reactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber.onNext(FluxMapFuseable.java:121)
    at reactor.core.publisher.Operators$ScalarSubscription.request(Operators.java:2071)
    at reactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber.request(FluxMapFuseable.java:162)
    at reactor.core.publisher.Operators$MultiSubscriptionSubscriber.set(Operators.java:1879)
    at reactor.core.publisher.Operators$MultiSubscriptionSubscriber.onSubscribe(Operators.java:1753)
    at reactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber.onSubscribe(FluxMapFuseable.java:90)
    at reactor.core.publisher.MonoJust.subscribe(MonoJust.java:54)
    at reactor.core.publisher.MonoMapFuseable.subscribe(MonoMapFuseable.java:59)
    at reactor.core.publisher.Mono.subscribe(Mono.java:3858)
    at reactor.core.publisher.FluxConcatMap$ConcatMapImmediate.drain(FluxConcatMap.java:442)
    at reactor.core.publisher.FluxConcatMap$ConcatMapImmediate.onSubscribe(FluxConcatMap.java:212)
    at reactor.core.publisher.FluxIterable.subscribe(FluxIterable.java:139)
    at reactor.core.publisher.FluxIterable.subscribe(FluxIterable.java:63)
    at reactor.core.publisher.FluxConcatMap.subscribe(FluxConcatMap.java:121)
    at reactor.core.publisher.MonoNext.subscribe(MonoNext.java:40)
    at reactor.core.publisher.MonoSwitchIfEmpty.subscribe(MonoSwitchIfEmpty.java:44)
    at reactor.core.publisher.MonoFlatMap.subscribe(MonoFlatMap.java:60)
    at reactor.core.publisher.MonoFlatMap.subscribe(MonoFlatMap.java:60)
    at reactor.core.publisher.MonoDefer.subscribe(MonoDefer.java:52)
    at reactor.core.publisher.MonoFlatMap$FlatMapMain.onNext(MonoFlatMap.java:150)
    at reactor.core.publisher.Operators$MonoSubscriber.complete(Operators.java:1515)
    at reactor.core.publisher.MonoZip$ZipCoordinator.signal(MonoZip.java:247)
    at reactor.core.publisher.MonoZip$ZipInner.onNext(MonoZip.java:329)
    at reactor.core.publisher.Operators$ScalarSubscription.request(Operators.java:2071)
    at reactor.core.publisher.MonoZip$ZipInner.onSubscribe(MonoZip.java:318)
    at reactor.core.publisher.MonoJust.subscribe(MonoJust.java:54)
    at reactor.core.publisher.Mono.subscribe(Mono.java:3858)
    at reactor.core.publisher.MonoZip.subscribe(MonoZip.java:128)
    at reactor.core.publisher.MonoFlatMap.subscribe(MonoFlatMap.java:60)
    at reactor.core.publisher.MonoDefer.subscribe(MonoDefer.java:52)
    at reactor.core.publisher.MonoDefer.subscribe(MonoDefer.java:52)
    at reactor.core.publisher.MonoPeekTerminal.subscribe(MonoPeekTerminal.java:61)
    at reactor.core.publisher.MonoPeekFuseable.subscribe(MonoPeekFuseable.java:74)
    at reactor.core.publisher.MonoDefer.subscribe(MonoDefer.java:52)
    at reactor.core.publisher.MonoDefer.subscribe(MonoDefer.java:52)
    at reactor.core.publisher.MonoOnErrorResume.subscribe(MonoOnErrorResume.java:44)
    at reactor.core.publisher.MonoOnErrorResume.subscribe(MonoOnErrorResume.java:44)
    at reactor.core.publisher.MonoPeekTerminal.subscribe(MonoPeekTerminal.java:61)
    at reactor.core.publisher.MonoOnErrorResume.subscribe(MonoOnErrorResume.java:44)
    at reactor.core.publisher.Mono.subscribe(Mono.java:3858)
    at reactor.core.publisher.MonoIgnoreThen$ThenIgnoreMain.drain(MonoIgnoreThen.java:172)
    at reactor.core.publisher.MonoIgnoreThen.subscribe(MonoIgnoreThen.java:56)
    at reactor.core.publisher.MonoPeekFuseable.subscribe(MonoPeekFuseable.java:70)
    at reactor.core.publisher.MonoPeekTerminal.subscribe(MonoPeekTerminal.java:61)
    at reactor.netty.http.server.HttpServerHandle.onStateChange(HttpServerHandle.java:64)
    at reactor.netty.tcp.TcpServerBind$ChildObserver.onStateChange(TcpServerBind.java:226)
    at reactor.netty.http.server.HttpServerOperations.onInboundNext(HttpServerOperations.java:442)
    at reactor.netty.channel.ChannelOperationsHandler.channelRead(ChannelOperationsHandler.java:91)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:374)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:360)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:352)
    at reactor.netty.http.server.HttpTrafficHandler.channelRead(HttpTrafficHandler.java:179)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:374)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:360)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:352)
    at io.netty.channel.CombinedChannelDuplexHandler$DelegatingChannelHandlerContext.fireChannelRead(CombinedChannelDuplexHandler.java:438)
    at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:328)
    at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:302)
    at io.netty.channel.CombinedChannelDuplexHandler.channelRead(CombinedChannelDuplexHandler.java:253)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:374)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:360)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:352)
    at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1421)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:374)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:360)
    at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:930)
    at io.netty.channel.epoll.AbstractEpollStreamChannel$EpollStreamUnsafe.epollInReady(AbstractEpollStreamChannel.java:794)
    at io.netty.channel.epoll.EpollEventLoop.processReady(EpollEventLoop.java:424)
    at io.netty.channel.epoll.EpollEventLoop.run(EpollEventLoop.java:326)
    at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:918)
    at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
    at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
    at java.lang.Thread.run(Thread.java:748)

this is my config

spring:
  cloud:
    gateway: 
      routes:
         - id: recharge-mobile
           uri: lb://recharge-mobile
           predicates:
             - Path=/recharge/mobile/**
           filters:
             - StripPrefix=1
prefectchen commented 2 years ago

how did you solve it

restart my project ,

wangliangliang123456789 commented 2 years ago

Upgrade version to 2.2.5+

zhangbo6248 commented 2 years ago

这是一个 Spring Cloud Gateway 新暴露的漏洞,参考: https://cloud.tencent.com/developer/article/1950978

phxuecan commented 2 years ago

how ?

prefectchen commented 2 years ago

Upgrade version to 2.2.5+ you also have this bug? I will try but what principle?

prefectchen commented 2 years ago

这是一个 Spring Cloud Gateway 新暴露的漏洞,参考: https://cloud.tencent.com/developer/article/1950978 感谢,我会发给领导看一下的 会试一下的

wangliangliang123456789 commented 2 years ago

reference https://github.com/spring-cloud/spring-cloud-gateway/issues/1915

prefectchen commented 2 years ago

reference #1915 I also see #1915 ,But it's a little different from his problem I am sure my project can run success, and this path /recharge/mobile/order also can access, but someday it can not access ex: 2022.03.07 this path can access ,but 2022.03.08 it can not access . in this time , nothing change on this server

tennisdd commented 2 years ago

I'm having the same problem,system worked normally for four months before this problem occurred.

prefectchen commented 2 years ago

I'm having the same problem,system worked normally for four months before this problem occurred.

do you know what reason? I restart my project it is work ,but i do not know reason

mikewoo commented 2 years ago

@prefectchen did you solve this problem?

prefectchen commented 2 years ago

@prefectchen did you solve this problem?

no but I restart my project it is work success, or change my nacos gateway.yml config

mm-soft-kp commented 2 years ago

What‘s the nacos version

spencergibb commented 2 years ago

2.1.x is no longer supported and this is fixed in later versions, please upgrade

prefectchen commented 2 years ago

What‘s the nacos version

1.3.2

prefectchen commented 2 years ago

2.1.x is no longer supported and this is fixed in later versions, please upgrade I also want to upgarde but my leader ask me what reason , can you tell me ?

prefectchen commented 2 years ago

Hello, author. I read the source code and found that assertions are stored in a collection, but I didn't find out why there is this problem. Can you explain it briefly? I'd like to know the reason very much I hope you can guide me in your spare time

thanks

------------------ 原始邮件 ------------------ 发件人: "spring-cloud/spring-cloud-gateway" @.>; 发送时间: 2022年3月9日(星期三) 中午12:01 @.>; @.**@.>; 主题: Re: [spring-cloud/spring-cloud-gateway] my gateway hava a bug java.lang.IndexOutOfBoundsException: Index: 0, Size: 0 (Issue #2542)

2.1.x is no longer supported and this is fixed in later versions, please upgrade

— Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android. You are receiving this because you were mentioned.Message ID: @.***>

litaodegithub commented 2 years ago

I'm having the same problem,system worked normally for four months before this problem occurred.

do you know what reason? I restart my project it is work ,but i do not know reason

I also encountered the same problem. In the near future, there will be an array of service reports that cross the boundary in a few days. Have you solved it

prefectchen commented 2 years ago

I'm having the same problem,system worked normally for four months before this problem occurred.

do you know what reason? I restart my project it is work ,but i do not know reason

I also encountered the same problem. In the near future, there will be an array of service reports that cross the boundary in a few days. Have you solved it

restart you project or change nacos config or upgrade

mm-soft-kp commented 2 years ago

@prefectchen Are there any problems with the upgraded version?which version did you upgrade to ?My problem is the same as yours

prefectchen commented 2 years ago

v2.2.5 you can try

------------------ 原始邮件 ------------------ 发件人: "spring-cloud/spring-cloud-gateway" @.>; 发送时间: 2022年3月10日(星期四) 上午10:27 @.>; @.**@.>; 主题: Re: [spring-cloud/spring-cloud-gateway] my gateway hava a bug java.lang.IndexOutOfBoundsException: Index: 0, Size: 0 (Issue #2542)

@prefectchen Are there any problems with the upgraded version?which version did you upgrade to ?My problem is the same as yours

— Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android. You are receiving this because you were mentioned.Message ID: @.***>

tennisdd commented 2 years ago

@prefectchen Are there any problems with the upgraded version?which version did you upgrade to ?My problem is the same as yours

I upgraded to version 2.2.5 and the problem was still there.

`2022-03-09 21:30:31.661 ERROR [api-gateway,a88e9c3de66a978a,a88e9c3de66a978a,true] 27583 --- [or-http-epoll-3] a.w.r.e.AbstractErrorWebExceptionHandler : [97ad7d15] 500 Server Error for HTTP GET "/actuator/gateway/routes/134694"

java.lang.IndexOutOfBoundsException: Index: 0, Size: 0 at java.util.ArrayList.rangeCheck(ArrayList.java:659) Suppressed: reactor.core.publisher.FluxOnAssembly$OnAssemblyException: Error has been observed at the following site(s): | checkpoint ? Handler org.springframework.cloud.gateway.actuate.GatewayControllerEndpoint#route(String) [DispatcherHandler] | checkpoint ? org.springframework.cloud.gateway.filter.WeightCalculatorWebFilter [DefaultWebFilterChain] | checkpoint ? com.alibaba.csp.sentinel.adapter.spring.webflux.SentinelWebFluxFilter [DefaultWebFilterChain] | checkpoint ? org.springframework.cloud.sleuth.instrument.web.TraceWebFilter [DefaultWebFilterChain] | checkpoint ? org.springframework.boot.actuate.metrics.web.reactive.server.MetricsWebFilter [DefaultWebFilterChain] | checkpoint ? HTTP GET "/actuator/gateway/routes/134694" [ExceptionHandlingWebHandler] Stack trace: at java.util.ArrayList.rangeCheck(ArrayList.java:659) at java.util.ArrayList.get(ArrayList.java:435) at org.springframework.cloud.gateway.route.RouteDefinitionRouteLocator.combinePredicates(RouteDefinitionRouteLocator.java:238) at org.springframework.cloud.gateway.route.RouteDefinitionRouteLocator.convertToRoute(RouteDefinitionRouteLocator.java:162) at reactor.core.publisher.FluxMap$MapSubscriber.onNext(FluxMap.java:100) at org.springframework.cloud.sleuth.instrument.reactor.ScopePassingSpanSubscriber.onNext(ScopePassingSpanSubscriber.java:96) at reactor.core.publisher.FluxFlatMap$FlatMapMain.tryEmit(FluxFlatMap.java:530) at reactor.core.publisher.FluxFlatMap$FlatMapInner.onNext(FluxFlatMap.java:972) at org.springframework.cloud.sleuth.instrument.reactor.ScopePassingSpanSubscriber.onNext(ScopePassingSpanSubscriber.java:96) at reactor.core.publisher.FluxMap$MapSubscriber.onNext(FluxMap.java:114) at org.springframework.cloud.sleuth.instrument.reactor.ScopePassingSpanSubscriber.onNext(ScopePassingSpanSubscriber.java:96) at reactor.core.publisher.MonoPublishOn$PublishOnSubscriber.run(MonoPublishOn.java:178) at reactor.core.scheduler.SchedulerTask.call(SchedulerTask.java:68) at reactor.core.scheduler.SchedulerTask.call(SchedulerTask.java:28) at org.springframework.cloud.sleuth.instrument.async.TraceCallable.call(TraceCallable.java:70) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:748)

2022-03-09 21:30:33.534 ERROR [api-gateway,,,] 27583 --- [ask-Scheduler-1] o.s.s.s.TaskUtils$LoggingErrorHandler : Unexpected error occurred in scheduled task

reactor.core.Exceptions$ErrorCallbackNotImplemented: java.lang.IndexOutOfBoundsException: Index: 0, Size: 0 `

yhtsnda commented 2 years ago

reactor.core.Exceptions$ErrorCallbackNotImplemented: java.lang.IndexOutOfBoundsException: Index: 0, Size: 0

I also have this problem , have you fixed it?

prefectchen commented 2 years ago

no but you can restart you project , this list will reload

------------------ 原始邮件 ------------------ 发件人: "spring-cloud/spring-cloud-gateway" @.>; 发送时间: 2022年3月10日(星期四) 上午10:51 @.>; @.**@.>; 主题: Re: [spring-cloud/spring-cloud-gateway] my gateway hava a bug java.lang.IndexOutOfBoundsException: Index: 0, Size: 0 (Issue #2542)

reactor.core.Exceptions$ErrorCallbackNotImplemented: java.lang.IndexOutOfBoundsException: Index: 0, Size: 0

I also have this problem , have you fixed it?

— Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android. You are receiving this because you were mentioned.Message ID: @.***>

yhtsnda commented 2 years ago

Terrible, I'm using it in a prod env

no but you can restart you project , this list will reload

prefectchen commented 2 years ago

me too , but my leader tell me restart gateway ,it is work . 

or you can change you nacos config (gateway.yml) ,the list always reload . be careful!!!!!

------------------ 原始邮件 ------------------ 发件人: "spring-cloud/spring-cloud-gateway" @.>; 发送时间: 2022年3月10日(星期四) 中午11:11 @.>; @.**@.>; 主题: Re: [spring-cloud/spring-cloud-gateway] my gateway hava a bug java.lang.IndexOutOfBoundsException: Index: 0, Size: 0 (Issue #2542)

Terrible, I'm using it in a prod env

no but you can restart you project , this list will reload

— Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android. You are receiving this because you were mentioned.Message ID: @.***>

momentwdj commented 2 years ago

@prefectchen @yhtsnda 我也遇到了这个问题。排查了很久解决了。 check一下access.log有没有/actuator/gateway/routes/xxxx类似的请求。然后有/actuator/gateway/refresh的请求。 原因是楼上有人提到的安全漏洞。然后公司内部or外部有人在做安全渗透。 在第一个接口OPST的时候创建含有可执行脚本的路由请求。其中predicates数组为空。 在第二个接口refresh的时候会导致出现#1915的bug然后导致请求都500. 解决方案是/actuator/gateway/*的外部请求全部禁止掉。

prefectchen commented 2 years ago

@prefectchen @yhtsnda 我也遇到了这个问题。排查了很久解决了。 check一下access.log有没有/actuator/gateway/routes/xxxx类似的请求。然后有/actuator/gateway/refresh的请求。 原因是楼上有人提到的安全漏洞。然后公司内部or外部有人在做安全渗透。 在第一个接口OPST的时候创建含有可执行脚本的路由请求。其中predicates数组为空。 在第二个接口refresh的时候会导致出现#1915的bug然后导致请求都500. 解决方案是/actuator/gateway/*的外部请求全部禁止掉。

在我的gateway日志中 确实找到了/actuator/gateway/routes请求 不过是get方式 而且没有其他参数 并没有 /actuator/gateway/refresh请求

/actuator/gateway/routes 这个路径爆出另一个错误

java.lang.IllegalStateException: Could not resolve view with name 'actuator/gateway/routes'.
    at org.springframework.web.reactive.result.view.ViewResolutionResultHandler.lambda$resolveViews$3(ViewResolutionResultHandler.java:277)
    at reactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber.onNext(FluxMapFuseable.java:107)
    at reactor.core.publisher.Operators$MonoSubscriber.complete(Operators.java:1515)
    at reactor.core.publisher.MonoCollectList$MonoCollectListSubscriber.onComplete(MonoCollectList.java:121)
    at reactor.core.publisher.FluxConcatMap$ConcatMapImmediate.drain(FluxConcatMap.java:360)
    at reactor.core.publisher.FluxConcatMap$ConcatMapImmediate.onComplete(FluxConcatMap.java:269)
    at reactor.core.publisher.Operators.complete(Operators.java:131)
    at reactor.core.publisher.FluxIterable.subscribe(FluxIterable.java:122)
    at reactor.core.publisher.FluxIterable.subscribe(FluxIterable.java:63)
    at reactor.core.publisher.FluxConcatMap.subscribe(FluxConcatMap.java:121)
    at reactor.core.publisher.MonoCollectList.subscribe(MonoCollectList.java:40)
    at reactor.core.publisher.MonoMapFuseable.subscribe(MonoMapFuseable.java:59)
    at reactor.core.publisher.MonoFlatMap.subscribe(MonoFlatMap.java:60)
    at reactor.core.publisher.MonoFlatMap$FlatMapMain.onNext(MonoFlatMap.java:150)
    at reactor.core.publisher.FluxSwitchIfEmpty$SwitchIfEmptySubscriber.onNext(FluxSwitchIfEmpty.java:67)
    at reactor.core.publisher.Operators$ScalarSubscription.request(Operators.java:2071)
    at reactor.core.publisher.Operators$MultiSubscriptionSubscriber.set(Operators.java:1879)
    at reactor.core.publisher.Operators$MultiSubscriptionSubscriber.onSubscribe(Operators.java:1753)
momentwdj commented 2 years ago

可以分析一下出问题之前短时间的access。然后结合你springcloud-gateway的版本看一下源码。

prefectchen commented 2 years ago

可以分析一下出问题之前短时间的access。然后结合你springcloud-gateway的版本看一下源码。

okk 我先把线上的程序弄好 然后去看下源码中的处理 感谢!!!

yhtsnda commented 2 years ago

@prefectchen @yhtsnda 我也遇到了这个问题。排查了很久解决了。 check一下access.log有没有/actuator/gateway/routes/xxxx类似的请求。然后有/actuator/gateway/refresh的请求。 原因是楼上有人提到的安全漏洞。然后公司内部or外部有人在做安全渗透。 在第一个接口OPST的时候创建含有可执行脚本的路由请求。其中predicates数组为空。 在第二个接口refresh的时候会导致出现#1915的bug然后导致请求都500. 解决方案是/actuator/gateway/*的外部请求全部禁止掉。

我检查下,问题和你的很类似,感谢兄弟提示

alpeshjikadra commented 2 years ago

I am also facing the same issue (Randomly) since last 2 days spring-boot version is : 2.0.4.RELEASE spring-cloud.version : Finchley.SR3

Issue is resolve by restarting gateway service, but face same problem after 1 day. So this is not reliable solution.

If anyone have permanent soultion, then please post here.

butter-fly commented 2 years ago

这是一个 Spring Cloud Gateway 新暴露的漏洞,参考: https://cloud.tencent.com/developer/article/1950978 感谢,我会发给领导看一下的 会试一下的

这个漏洞我们也出现了 只出现在线上 测试暂时没有出现过

alpeshjikadra commented 2 years ago

As a solution I have upgrade my gateway service to : SpringBoot : 2.5.12 Spring cloud dependency to : 2020.0.5

I see on fix in this version as below, They have gracefully handle the condition.

private AsyncPredicate<ServerWebExchange> combinePredicates(RouteDefinition routeDefinition) {
    List<PredicateDefinition> predicates = routeDefinition.getPredicates();
    if (predicates == null || predicates.isEmpty()) {
        // this is a very rare case, but possible, just match all
        return AsyncPredicate.from(exchange -> true);
    }
    AsyncPredicate<ServerWebExchange> predicate = lookup(routeDefinition,
            predicates.get(0));

    for (PredicateDefinition andPredicate : predicates.subList(1,
            predicates.size())) {
        AsyncPredicate<ServerWebExchange> found = lookup(routeDefinition,
                andPredicate);
        predicate = predicate.and(found);
    }

    return predicate;
}
butter-fly commented 2 years ago

这是来自QQ邮箱的假期自动回复邮件。   您好,我最近正在休假中,无法亲自回复您的邮件。我将在假期结束后,尽快给您回复。

NadymAtKayana commented 2 years ago

Any updates about this issue. I'm facing the same issue with my gateway server.

Spring-Boot version:2.2.5.RELEASE Spring Cloud Version:Hoxton.SR3

butter-fly commented 2 years ago

这是来自QQ邮箱的假期自动回复邮件。   您好,我最近正在休假中,无法亲自回复您的邮件。我将在假期结束后,尽快给您回复。

litaodegithub commented 2 years ago

这是来自QQ邮箱的假期自动回复邮件。   您好,我最近正在休假中,无法亲自回复您的邮件。我将在假期结束后,尽快给您回复。

litaodegithub commented 2 years ago

这是来自QQ邮箱的假期自动回复邮件。   您好,我最近正在休假中,无法亲自回复您的邮件。我将在假期结束后,尽快给您回复。

butter-fly commented 2 years ago

这是来自QQ邮箱的假期自动回复邮件。   您好,我最近正在休假中,无法亲自回复您的邮件。我将在假期结束后,尽快给您回复。

spencergibb commented 1 year ago

We're cleaning out the issue tracker and closing issues that we've not seen much demand to fix. Feel free to comment with additional justifications if you feel that this one should not have been closed.

litaodegithub commented 1 year ago

这是来自QQ邮箱的假期自动回复邮件。   您好,我最近正在休假中,无法亲自回复您的邮件。我将在假期结束后,尽快给您回复。

30624770 commented 1 year ago

可以分析一下出问题之前短时间的access。然后结合你springcloud-gateway的版本看一下源码。

okk 我先把线上的程序弄好 然后去看下源码中的处理 感谢!!!

请问找到问题原因了吗

butter-fly commented 1 year ago

这是来自QQ邮箱的假期自动回复邮件。   您好,我最近正在休假中,无法亲自回复您的邮件。我将在假期结束后,尽快给您回复。

litaodegithub commented 1 year ago

这是来自QQ邮箱的假期自动回复邮件。   您好,我最近正在休假中,无法亲自回复您的邮件。我将在假期结束后,尽快给您回复。