-
CSR
-
Resolution: Approved
-
P4
-
None
-
behavioral
-
minimal
-
Throwing an OOME is more correct than an IAE. Do not expect any app expecting IAE on that occasion
-
Java API
-
SE
Summary
Throw an OutOfMemoryError
in java.nio.charset.CharsetEn/Decoder.en/decode(Char/ByteBuffer)
always if the requested-sized buffer cannot be allocated.
Problem
If a large size of the input buffer (close to Integer.MAX_VALUE
) is specified on CharsetDecoder.decode(ByteBuffer)
, it incorrectly throws an IllegalArgumentException
due to an int
overflow.
Solution
Explicitly specify OutOfMemoryError
in the method descriptions of CharsetEn/Decoder(Char/ByteBuffer)
in case the array backing the output buffer cannot be allocated.
Specification
Add the following @throws
section in the method description of CharsetEncoder.encode(CharBuffer)
:
* @throws OutOfMemoryError
* If the output byte buffer for the requested size of the input
* character buffer cannot be allocated
Add the following @throws
section in the method description of CharsetDecoder.decode(ByteBuffer)
:
* @throws OutOfMemoryError
* If the output character buffer for the requested size of input
* byte buffer cannot be allocated
- csr of
-
JDK-8272613 CharsetDecoder.decode(ByteBuffer) throws IllegalArgumentException
-
- Closed
-