JDK-8067102 : CharsetDecoder decode in JDK8 results in different behavior compared to JDK7
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.nio.charsets
  • Affected Version: 8u11
  • Priority: P3
  • Status: Closed
  • Resolution: Not an Issue
  • OS: os_x
  • CPU: x86
  • Submitted: 2014-11-12
  • Updated: 2014-12-10
  • Resolved: 2014-12-10
Related Reports
Relates :  
Description
FULL PRODUCT VERSION :
java version "1.8.0_11"
Java(TM) SE Runtime Environment (build 1.8.0_11-b12)

ADDITIONAL OS VERSION INFORMATION :
MacOS 13.4.0 Darwin Kernel Version 13.4.0

A DESCRIPTION OF THE PROBLEM :
Running the below code results in different behavior in JDK8 from JDK7

@Test
  public void testTest() {
    CharsetDecoder decoder = Charsets.UTF_8.newDecoder();

    decoder.onMalformedInput(CodingErrorAction.REPLACE);
    decoder.onUnmappableCharacter(CodingErrorAction.REPLACE);

    ByteBuffer buf = ByteBuffer.allocate(20);
    buf.put(new byte[] { (byte)0xf8, (byte)0xa1, (byte)0xa1, (byte)0xa1,
            (byte)0xa1 });
    buf.flip();

    CharBuffer cbuf = CharBuffer.allocate(1);
    CoderResult res = decoder.decode(buf, cbuf, false);
    System.out.println(decoder.getClass().getName());
    System.out.println("Pos --- "+buf.position()+ "  cbuf pos --"+cbuf.position());
}

Jdk 7 output -->Pos --- 5  cbuf pos --1
Jdk 8 output -->Pos --- 1  cbuf pos --1

REGRESSION.  Last worked in version 7u67


REPRODUCIBILITY :
This bug can be reproduced always.


Comments
See (2) of 7096080 The behavior of handing the unsupported 5-bytes is changed based on the unicode standard update.
10-12-2014

No response was received from the submitter. As there is not enough information in this report to make headway it is being closed. If this issue is seen, please open a new report with all necessary information. This report ID can be referenced.
04-12-2014

Sent an email to submitter inquiring more information about the test case.
18-11-2014

Test case is referring to com.google.common.base.Charsets. Will need one a test case that does not depend on third party api since the expected results may also depend on a specific release of the third party api.
12-11-2014