close

[Solved] org.springframework.core.io.buffer.DataBufferLimitException: Exceeded limit on max bytes to buffer

Hello Guys, How are you all? Hope You all Are Fine. Today When I am sending or receiving file I am facing following error org.springframework.core.io.buffer.DataBufferLimitException: Exceeded limit on max bytes to buffer in Java. So Here I am Explain to you all the possible solutions here.

Without wasting your time, Let’s start This Article to Solve This Error.

How org.springframework.core.io.buffer.DataBufferLimitException: Exceeded limit on max bytes to buffer Error Occurs ?

When I am sending or receiving file I am facing following error.

org.springframework.core.io.buffer.DataBufferLimitException: Exceeded limit on max bytes to buffer : 262144
    at org.springframework.core.io.buffer.LimitedDataBufferList.raiseLimitException(LimitedDataBufferList.java:101)
    Suppressed: reactor.core.publisher.FluxOnAssembly$OnAssemblyException

How To Solve org.springframework.core.io.buffer.DataBufferLimitException: Exceeded limit on max bytes to buffer Error ?

  1. How To Solve org.springframework.core.io.buffer.DataBufferLimitException: Exceeded limit on max bytes to buffer Error ?

    To Solve org.springframework.core.io.buffer.DataBufferLimitException: Exceeded limit on max bytes to buffer Error You just need to specify maximum memory size in configuration property in Spring Boot: spring: codec: max-in-memory-size: 10MB Now, your error must be solved.

  2. org.springframework.core.io.buffer.DataBufferLimitException: Exceeded limit on max bytes to buffer

    To Solve org.springframework.core.io.buffer.DataBufferLimitException: Exceeded limit on max bytes to buffer Error You just need to specify maximum memory size in configuration property in Spring Boot: spring: codec: max-in-memory-size: 10MB Now, your error must be solved.

Solution 1: add spring.codec.max-in-memory-size in config file

You just need to specify maximum memory size in configuration property in Spring Boot.

spring:
  codec:
    max-in-memory-size: 10MB

Now, your error must be solved.

Solution 2: create Bean in the main Springbootapplication class.

First of Just create Bean in the main Springbootapplication class. Just like below.

@Bean
public WebClient getWebClientBuilder(){
    return   WebClient.builder().exchangeStrategies(ExchangeStrategies.builder()
            .codecs(configurer -> configurer
                      .defaultCodecs()
                      .maxInMemorySize(16 * 1024 * 1024))
                    .build())
                  .build();
}

Now, Just use WebClient class. Just like this.

        WebClient webClient;

        public void test(){
         String out = webClient
                      .get()
                      .uri("end point of an API")
                      .retrieve()
                      .bodyToMono(String.class)
                     .block();

         sysout(out)

Now, Your error must be solved.

Summary

It’s all About this issue. Hope all solution helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which solution worked for you?

Also, Read

Please Rate Our Solution to Motivate Us For Give Our Best

Leave a Comment