RFR JDK-8176379: java.util.Base64 mime encoder behaves incorrectly if initialized with a line length of size 1-3

Xueming Shen xueming.shen at oracle.com
Fri Jan 26 23:32:14 UTC 2018


Please help review the change for JDK-8176379

issue: https://bugs.openjdk.java.net/browse/JDK-8176379
webrev: http://cr.openjdk.java.net/~sherman/8176379/webrev

It appears the spec is somewhat misleading and/or incorrect in this corner
case. And the implementation of the mime type encoder OutputStream does
not expect a "length==0" mime encoder. The difference behavior of the
non-stream-type encoder and stream-type encoder comes from

in non-stream-type case, we always have a " > 0" guard as

            if (linemax > 0 && slen > linemax / 4 * 3)
                 slen = linemax / 4 * 3

but in stream-type we don't.

         private void checkNewline() throws IOException {
             if (linepos == linemax) {
                 linepos = 0;

The proposed change here is to clarify the spec and the implementation
to use a non-mime type encoder (no line separator) when the rounded down
mime line length is smaller than 4.

We probably need a CSR for this spec clarification, if the proposed 
change is


More information about the core-libs-dev mailing list