Hi

We are seeing a really odd behaviour after upgrading yesterday to 1.1.4 from 1.1.3

Basically if we see an invalid message (we deem it invalid as part of our business logic) we just throw an exception and close the ioSession.
It worked perfectly up to 1.1.3 and is completely buggered in 1.1.4...
In 1.1.4 we get tons of exception because of the newly introduced while loop (while (in.hasRemaining())) in the try {} catch block of the ProtocolCodecFilter messageReceived(...)

MINA 1.1.3
==========

    @Override
public void messageReceived(NextFilter nextFilter, IoSession session,
            Object message) throws Exception {
        if (!(message instanceof ByteBuffer)) {
            nextFilter.messageReceived(session, message);
            return;
        }

        ByteBuffer in = (ByteBuffer) message;
        ProtocolDecoder decoder = getDecoder(session);
ProtocolDecoderOutput decoderOut = getDecoderOut(session, nextFilter);

        try {
            synchronized (decoderOut) {
                decoder.decode(session, in, decoderOut);
            }
        } catch (Throwable t) {
            ProtocolDecoderException pde;
            if (t instanceof ProtocolDecoderException) {
                pde = (ProtocolDecoderException) t;
            } else {
                pde = new ProtocolDecoderException(t);
            }
            pde.setHexdump(in.getHexDump());
            throw pde;
        } finally {
            // Dispose the decoder if this session is connectionless.
            if (session.getTransportType().isConnectionless()) {
                disposeDecoder(session);
            }

            // Release the read buffer.
            in.release();

            decoderOut.flush();
        }
    }



MINA 1.1.4
==========
    @Override
public void messageReceived(NextFilter nextFilter, IoSession session,
            Object message) throws Exception {
        if (!(message instanceof ByteBuffer)) {
            nextFilter.messageReceived(session, message);
            return;
        }

        ByteBuffer in = (ByteBuffer) message;
        ProtocolDecoder decoder = getDecoder(session);
ProtocolDecoderOutput decoderOut = getDecoderOut(session, nextFilter);

        try {
            while (in.hasRemaining()) {            <<< What for???
                int oldPos = in.position();
                try {
                    synchronized (decoderOut) {
                        decoder.decode(session, in, decoderOut);
                    }
                    // Finish decoding if no exception was thrown.
                    decoderOut.flush();
                    break;
                } catch (Throwable t) {
                    ProtocolDecoderException pde;
                    if (t instanceof ProtocolDecoderException) {
                        pde = (ProtocolDecoderException) t;
                    } else {
                        pde = new ProtocolDecoderException(t);
                    }
                    pde.setHexdump(in.getHexDump());

                    // Fire the exceptionCaught event.
                    decoderOut.flush();
                    nextFilter.exceptionCaught(session, pde);

// Stop retrying if the buffer position didn't change
                    // because retrying can cause an infinite loop.
                    if (in.position() == oldPos) {
                        break;
                    }
                }
            }
        } finally {
            // Release the read buffer.
            in.release();
        }
    }

I can't see anything related to this change in the changelog and the reason why.

This is a major regression considering that if you have a message that is 1000 bytes long and the 1st byte is deemed invalid and you want to close this ioSession you will get 1000 times the same exception that fills up MBs of logs in seconds!!!

Right now we're going back to 1.1.3

--
Frederic P. Soulier
OpenPGP key available on http://pgpkeys.mit.edu/
1024D/BA6700ED   49A6 8E8E 4230 8D41 1ADE  B649 3203 1DD2 BA67 00ED

Reply via email to