Spring Cloud Gateway Request Pending

使用的Spring Boot版本是2.0.0.RELEASE,Spring Cloud版本是Finchley.M8

请求返回200仍处于Pending状态

项目中使用gateway时出现一些问题,部分请求已经正确返回200了,但是仍然显示在Pending。有时是ajax请求,有时是一些静态资源css,js之类的。

在这里插入图片描述

经过查找在GitHub的spring-cloud-gateway的issues中有人提过此bug。

解决方法是spring-cloud-starter-gateway的包中reactor-netty升级到0.7.7.RELEASE及以上版本就可以。

Spring Boot2.0.0对应的reactor-netty版本是0.7.5.RELEASE,升级到2.0.2应该就可以了。但是由于没找到Spring Boot2.0.2对应的Spring Cloud版本,所以现在将Spring Boot升级到2.0.3.RELEASE,Spring Cloud升级到Finchley.RELEASE 。此时的reactor-netty版本是0.7.8.RELEASE.

静态文件,部分请求返回NPE

Spring Boot升级到2.0.3后部分Ajax请求和静态资源时出现NPE,但将这个链接http://localhost:10003/api/admin/plugins/util.js使用浏览器打开可以正常得到js的

2019-05-31 16:00:28.038 [reactor-http-nio-5] ERROR o.s.b.a.w.r.error.DefaultErrorWebExceptionHandler - Failed to handle request [GET http://localhost:10003/api/admin/plugins/util.js]  
java.lang.NullPointerException: null
	at java.util.concurrent.ConcurrentHashMap.putVal(ConcurrentHashMap.java:1011)
	at java.util.concurrent.ConcurrentHashMap.put(ConcurrentHashMap.java:1006)
	at org.springframework.cloud.gateway.filter.NettyRoutingFilter.lambda$filter$3(NettyRoutingFilter.java:117)
	

官方issues上有类似的bug提出 https://github.com/spring-cloud/spring-cloud-gateway/issues/392

查看spring-cloud-starter-gateway的依赖,虽然版本是2.0.3,但是spring-cloud-gateway-core还是2.0.0

springcloud版本依赖

解决方法为升级 spring-cloud-gateway-core 依赖

<dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-gateway</artifactId>
            <version>2.0.3.RELEASE</version>
            <exclusions>
                <exclusion>
                    <groupId>org.springframework.cloud</groupId>
                    <artifactId>spring-cloud-gateway-core</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-gateway-core</artifactId>
            <version>2.0.3.RELEASE</version>
        </dependency>

参考

https://www.cnblogs.com/dalaoyang/p/10521534.html

http://xiaoqiangge.com/aritcle/1545889008833.html

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值