Carter Kozak created HTTPCORE-646:
-------------------------------------

             Summary: ChunkedInputStream often creates a garbage buffer on 
close to read zero bytes
                 Key: HTTPCORE-646
                 URL: https://issues.apache.org/jira/browse/HTTPCORE-646
             Project: HttpComponents HttpCore
          Issue Type: Improvement
          Components: HttpCore
    Affects Versions: 5.0.1
            Reporter: Carter Kozak


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.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to