Summary
Base64.Encoder.encode and Base64.Decoder.decode should throw OutOfMemoryError if the output bytes array/buffer of the needed size can not be allocated.
Problem
The existing Base64.Encoder.encode and Base64.Decoder.decode methods do not specify the error to be thrown when the encoded/decoded byte array of needed size can not be allocated. The current implementation throws an unspecified exception, for example, NegativeArraySizeException.
Solution
Add an OutOfMemoryError
statement to Base64.Encoder
and Base64.Decoder
, if encode
and decode
methods fail to allocate the output array/buffer or memory.
Specification
Update Base64.Encoder spec
from:
* <p> Unless otherwise noted, passing a {@code null} argument to
* a method of this class will cause a
* {@link java.lang.NullPointerException NullPointerException} to
* be thrown.
to:
* <p> Unless otherwise noted, passing a {@code null} argument to
* a method of this class will cause a
* {@link java.lang.NullPointerException NullPointerException} to
* be thrown.
* <p> If the encoded byte output of the needed size can not
* be allocated, the encode methods of this class will
* cause an {@link java.lang.OutOfMemoryError OutOfMemoryError}
* to be thrown.
Update Base64.Decoder spec
from:
* <p> Unless otherwise noted, passing a {@code null} argument to
* a method of this class will cause a
* {@link java.lang.NullPointerException NullPointerException} to
* be thrown.
to:
* <p> Unless otherwise noted, passing a {@code null} argument to
* a method of this class will cause a
* {@link java.lang.NullPointerException NullPointerException} to
* be thrown.
* <p> If the decoded byte output of the needed size can not
* be allocated, the decode methods of this class will
* cause an {@link java.lang.OutOfMemoryError OutOfMemoryError}
* to be thrown.
- csr of
-
JDK-8210583 Base64.Encoder incorrectly throws NegativeArraySizeException
-
- Closed
-