CSR :
|
|
Relates :
|
As mentioned in the JDK-8210583 bug description about Base64.Encoder.encode throwing NegativeArraySizeException, the Base64.Decoder.decode method was also throwing NegativeArraySizeException while decoding the large arrays near Integer.MAX_VALUE, which is only because of the intermediate result integer overflow while computing the decoded output length, not the final result. Instead of throwing OOME (as done by JDK-8210583 fix), the NegativeArraySizeException issue could have been resolved by storing that intermediate result with larger type "long" and then converting the final result to integer. So there is not need for OOME due to overflow as it does not happen with final result. byte[] input = new byte[Integer.MAX_VALUE-2]; byte[] output = Base64.getDecoder().decode(input); The above snippet throws OOME ("Decoded size is too large") even if the output length is less than Integer.MAX_VALUE