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

TextLineCodecFactory does not decode correct if there is a nullbyte within the string

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.0.4
    • Fix Version/s: None
    • Component/s: Filter
    • Labels:
      None
    • Environment:
      Ubuntu Linux, Java 1.6.0_26, Mina 2.0.4

      Description

      I am running a tcp+udp server using mina. As decoder i am using TextLineCodecFactory. Some of the messages we receive contain a nullbyte at the beginning. In that case the received message is an empty string, so the message gets lost.

      Example:
      //acceptor:
      acceptor.getFilterChain().addLast("codec", new ProtocolCodecFilter(new TextLineCodecFactory()));
      acceptor.setHandler(myHandler);

      //test message with additional nullbyte at the beginning
      String s = new String(new byte[]

      {0, 77, 105, 110, 97}

      ); //nullbyte + "Mina"

      //now send s to mina
      //myHandler:
      public void messageReceived(IoSession session, Object message) throws Exception {
      String res = (String) message; //length is 0 instead of 5
      }

      See attached maven-project with unit-test

        Attachments

        1. mina_nullbyte_bug.zip
          5 kB
          Martin Leuschner

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              nitram Martin Leuschner
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: