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

StreamIoHandler can flush garbled data.

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.0.1, 1.0.2, 1.0.3, 1.1.0
    • 1.0.4, 1.1.1
    • Handler
    • 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

            trustin Trustin Lee
            trustin Trustin Lee
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: