title: Spring service returns empty result if the real result is to large
body: <p>I am working on a Spring service that gets data from DB and returns a JSON with a list of objects.
  This service returns ALL records that we have in a specific table. In total about 10,000 records more or less.</p>
  <p>The method of obtaining data is fast (Using Threads), but when the service returns the results of the request it is when it is slow.</p>
  <p>Also when the size of the json exceeds 700 records we get an empty result. Each object in the list has about 70 fields.</p>
  <p>Does anyone know any method so that Spring does not take so long to return the results?</p>
  <p>Is there a response size limit for a Spring service?</p>
  <p>Here you have the code</p>
  <pre><code>    public String getData(final Pageable pageable) throws Exception {
          
          final int numberOfThreads = 10;
  
          final StringBuilder str = new StringBuilder();
          str.append(&quot;{&quot; + &quot;\&quot;content\&quot;: [&quot;);
  
          // Here we are obtaining all the data in diferents treads and appending in variable String 
           strContent 
          
          String strContent = getDataByThreads(numberOfThreads);
          // Here strContent contains 10.000 or more objects in JSON format
  
  
          logger.info(&quot; -------------- END OF {} THREADS  ----------------- &quot;, numberOfThreads);
  
          final long totalPages = (totalCount / fetchSize) + 1;
          final boolean last = Math.ceil(totalPages) == pageable.getPageNumber();
          final boolean first = pageable.getPageNumber() == 0;
  
          // Mounting the response JSON
          str.append(strContent);
          str.append(&quot;],&quot;);
          str.append(&quot;\&quot;last\&quot;: &quot; + last + &quot;,&quot;);
          str.append(&quot;\&quot;totalElements\&quot;: &quot; + totalCount + &quot;,&quot;);
          str.append(&quot;\&quot;totalPages\&quot;: &quot; + totalPages + &quot;,&quot;);
          str.append(&quot;\&quot;first\&quot;: &quot; + first + &quot;,&quot;);
          str.append(&quot;\&quot;numberOfElements\&quot;: &quot; + fetchSize + &quot;,&quot;);
          str.append(&quot;\&quot;size\&quot;: &quot; + fetchSize + &quot;,&quot;);
          str.append(&quot;\&quot;number\&quot;: &quot; + pageable.getPageNumber());
          str.append(&quot;}&quot;);
  
          // Here is where Spring takes a long time...
          return str.toString();
      }
  </code></pre>
  <p>As you can see, we return a JSON in String format because the objects have dynamic fields and are not fixed.</p>
  <p>Thank you.</p>