-
Notifications
You must be signed in to change notification settings - Fork 38.8k
Description
We are observing OutOfMemoryError
s when the WebClient
receives large responses containing characters that cannot be represented by Latin1
encoding.
This is especially critical, because the exception occurs here in decodeInternal
before the data buffer is released and I suspect this is causing a memory leak.
I would expect a WebClientResponseException
to be thrown and the data buffer to be released correctly.
Here is a demo that shows that WebClientResponseException
s are thrown correctly for most cases (response larger 2GB, response larger maxInMemorySize
), but not in the specific case where:
- response within
maxInMemorySize
- AND response smaller
Integer.MAX_VALUE
- AND response larger
Integer.MAX_VALUE >> 1
(StringUTF16.MAX_LENGTH) - AND response containing character that cannot be represented by Latin1.
response1500MBWithEmoji2000MBMaxMemoryThrowsOutOfMemoryError
is the important test case.
If you have an idea where to throw a proper exception before attempting to create a String I would be happy to contribute.