Uploaded image for project: 'MINA'
  1. MINA
  2. DIRMINA-1181

Exception thrown when attempting to decode certain UTF-16 chars

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 2.1.6
    • 2.2.4, 2.0.26, 2.1.9
    • Core
    • None
    • Linux, Windows, Java 8, Java 17

    Description

      When trying to decode a UTF16BE input stream containing characters ot the form \uxx00, for example \u0100 (capital A with macron) the method AbstractIoBuffer.getString(CharsetDecoder) incorrectly interprets the second byte as a null terminator (causing a java.nio.charset.MalformedInputException to be thrown) despite this null byte being mid-character (at an odd index). The attached file, MacronTest, demonstrates the issue and when run produces the following output:

      buf = ABC
      Exception in thread "main" java.nio.charset.MalformedInputException: Input length = 1
          at java.base/java.nio.charset.CoderResult.throwException(CoderResult.java:274)
          at org.apache.mina.core.buffer.AbstractIoBuffer.getString(AbstractIoBuffer.java:1669)
          at MacronTest.<init>(MacronTest.java:61)
          at MacronTest.main(MacronTest.java:13)

      It looks like this issue is also in the 2.2.X branch (3.X/trunk not checked).

      Attachments

        1. MacronTest.java
          2 kB
          Pete Disdale
        2. MacronTest-1.java
          2 kB
          Pete Disdale

        Activity

          People

            Unassigned Unassigned
            pmguy Pete Disdale
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: