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

StreamIoHandler can flush garbled data.

VotersWatch issueWatchersLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 1.0.1, 1.0.2, 1.0.3, 1.1.0
    • Fix Version/s: 1.0.4, 1.1.1
    • Component/s: Handler
    • Labels:
      None

      Description

      The OutputStream which StreamIoHandler provided doesn't perform defensive copy. Some wrapper OutputStreams and Writers (e.g. BufferedOutputStream and BufferedWriter) reuse their internal byte array, and causes the byte buffer to be modified before it's actually written out to the channel. There are two solutions:

      1) Perform defensive copy in write(byte[], int, int):

      public void write( byte[] b, int off, int len ) throws IOException

      { write( ByteBuffer.wrap( (byte[]) b.clone(), off, len ) ); }

      2) Wait for the WriteFuture for every operation.

      The former sounds better IMO.

        Attachments

          Activity

            People

            • Assignee:
              trustin Trustin Lee
              Reporter:
              trustin Trustin Lee

              Dates

              • Created:
                Updated:
                Resolved:

                Issue deployment