RFR 8014217: Base64.getXDecoder().wrap(...).read() doesn't throw exception for an incorrect number of padding chars in the final unit

Alan Bateman Alan.Bateman at oracle.com
Tue May 14 19:47:00 UTC 2013

On 14/05/2013 20:32, Xueming Shen wrote:
> It has been discussed before that the IOE is preferred in case of the 
> wrapped
> decoding stream. The spec of wrap() does mention that "IOE when reading
> bytes that can not be decoded".
> So personally I feel it has been "covered", but if preferred, it can 
> go further as
> "If there is padding character present in the final unit, the correct 
> number of padding
> character(s) must be present, otherwise IllegalArgumentException (or 
> IOException in case
> of decoding from the wrapped base64 stream), is thrown during decoding."?
> -Sherman
Right, this has come up before. The intention is that IAE be thrown if 
the array/buffer provided as an argument is invalid, meaning containing 
bytes that cannot be decoded. For the wrap methods then there aren't any 
invalid arguments, instead it is bytes read from the stream that can't 
be decoded. I believe we agreed here to keep this consistent with other 
InputStream usages where malformed data or decoding causes IOException 
to be thrown. If there is any doubt then it would be good to clarify 
this, maybe "IOException when reading from a a base64 stream".


More information about the core-libs-dev mailing list