RFR: JDK-8007799 Base64.getEncoder(0, byte[]) returns encoder that unexpectedly inserts line separator when using some of the encoding methods

Mark Sheppard mark.sheppard at oracle.com
Wed Mar 27 16:01:47 UTC 2013


Hi,
    please oblige and review the webrev below as a fix for the issue 
raised in JDK-8007799

http://cr.openjdk.java.net/~msheppar/8007799/webrev.00/

Description:
"Specification for the method
java.util.Base64.getEncoder(int lineLength, byte[] lineSeparator)

says:
Parameters:
     lineLength - the length of each output line (rounded down to 
nearest multiple of 4). If lineLength <= 0 the output will not be 
separated in lines

However if a zero line length is specified encoding methods wrap() and 
encode(ByteBuffer src, ByteBuffer dst, int bytesOut) return encoded 
string which starts from the given line separator. "

the patch adds a check for linemax  > 0 whenever a line separator might 
be added, and adds an new test case.

regards
Mark



More information about the core-libs-dev mailing list