Uploaded image for project: 'HttpComponents HttpCore'
  1. HttpComponents HttpCore
  2. HTTPCORE-646

ChunkedInputStream often creates a garbage buffer on close to read zero bytes

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 5.0.1
    • 5.0.2
    • HttpCore
    • None

    Description

      I profiled a service using hc5 to read chunked responses which are parsed using jackson directly from the entity stream. I've found that a new 4 KiB buffer is created to drain remaining bytes every time close is called, despite the read never producing any data because the next read discovers the terminating chunk.

      This scenario is likely any time that self-terminating data is parsed, the consumer is able to stop reading prior to receiving an end-of-stream.

      It's likely that sufficient data already exists in the SessionInputBuffer to avoid unnecessary buffers. To solve this issue it may be enough to attempt a single-byte read prior to using the buffer, or an efficient InputStream.skip(long) could be implemented.
      A globally shared buffer would solve this, however there may be security concerns using a static buffer to dump trailing contents which may include sensitive data, accessible elsewhere in the jvm.

      Attachments

        Activity

          People

            Unassigned Unassigned
            ckozak Carter Kozak
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0h
                0h
                Logged:
                Time Spent - 50m
                50m