Exceeded limit on max bytes to buffer : 262144

springboot版本 2.7.3

springcloud版本 2021.0.3

POST请求的body是1M多,请求网关提示报错。

org.springframework.core.io.buffer.DataBufferLimitException: Exceeded limit on max bytes to buffer : 262144
    at org.springframework.core.io.buffer.LimitedDataBufferList.raiseLimitException(LimitedDataBufferList.java:99)
    Suppressed: reactor.core.publisher.FluxOnAssembly$OnAssemblyException: 
Error has been observed at the following site(s):
    *__checkpoint ⇢ springfox.boot.starter.autoconfigure.SwaggerUiWebFluxConfiguration$CustomWebFilter [DefaultWebFilterChain]
    *__checkpoint ⇢ org.springframework.cloud.gateway.filter.WeightCalculatorWebFilter [DefaultWebFilterChain]

配置增加大小也没有生效

spring:
  application:
    # 应用名称
    name: app-service
  codec:
    max-in-memory-size: 31457280

经过排查是添加了注解@EnableWebFlux导致配置大小失效!!!!

目前简单处理先去掉了该注解

为什么会导致失效呢?

查看源码发现原来增加@EnableWebFlux

发现这个注解是去加载类DelegatingWebFluxConfiguration而不是WebFluxAutoConfiguration。

但是修改大小的配置是在WebFluxAutoConfiguration类中去加载的。

感觉是bug?????


版权声明:本文为whiteForever原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。