Uploaded image for project: 'Spring Framework'
  1. Spring Framework
  2. SPR-17268

Proper way to dispose of Response

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Complete
    • Affects Version/s: 5.0.8
    • Fix Version/s: 5.1 GA
    • Component/s: Reactive, Web, Web:Client
    • Labels:
      None

      Description

      Recently there was a fix that addressed some potential memory leaks if there were errors in the response to the Webclient.  Fix is here

      https://jira.spring.io/browse/SPR-17025

      If using exchange() what is the proper way to dispose of a response?  Can leaks still occur on bodyToMono(String.class) ? Trying to understand if this fix was specific to cases where bytebuffers are used e.g. 

      return join(response.body(BodyExtractors.toDataBuffers()))
       .map(dataBuffer -> {
       byte[] bytes = new byte[dataBuffer.readableByteCount()];
       dataBuffer.read(bytes);
       DataBufferUtils.release(dataBuffer);
       return bytes;
       }).then();
      

      or everywhere.

      The above snippet is used directly in WebClients default error handler - so would like to know if this is the only "safe" way to deal with disposing a response if a non 200 status code has taken place after using exchange.

       

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              arjen.poutsma Arjen Poutsma
              Reporter:
              david.terk David Terk
              Last updater:
              Spring Issuemaster
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Days since last comment:
                1 year, 36 weeks, 5 days ago