The Util class looks like this:

public class Util {

        private Util() {
        }

        public static boolean prefixedDataAvailable(IoBuffer in, int
prefixLength,
                        int maxLength) {
                if (in.remaining() < prefixLength)
                        return false;

                int dataLength;

                switch (prefixLength) {
                case 1:
                        dataLength = in.getUnsigned(in.position());
                        break;
                case 2:
                        dataLength = in.getUnsignedShort(in.position());
                        break;
                case 4:
                        dataLength = in.getInt(in.position());
                        break;
                default:
                        throw new
IllegalArgumentException("prefixLength: " + prefixLength);
                }

                if (dataLength < 0 || dataLength > maxLength) {
                        throw new BufferDataException("dataLength: " +
dataLength);
                }
                return in.remaining() >= dataLength;
        } 

BR
-----Original Message-----
From: Wenrui Guo [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, July 23, 2008 9:17 PM
To: [email protected]
Subject: RE: BufferedData continue to grow up - 

The following two encoder classes are taking the role to transform
messages.

public class PDUWrapEncoder<T> implements MessageEncoder<T> {


        public void encode(IoSession session, T message,
ProtocolEncoderOutput out)
                        throws Exception {
                PDU pdu = (PDU) message;
                out.write(IoBuffer.wrap(pdu.getData().getBuffer()));
        }

}

public class ForwardMsgEncoder<T> implements MessageEncoder<T> {

        public void encode(IoSession session, T message,
ProtocolEncoderOutput out)
                        throws Exception {
        }
}

I already debugged the application under light workload, it seems ok.
But as long as I apply more than one thousand messages to the
application, it always throws the exception of dataLength.

I think maybe some mistaken inside my source code. Is there anybody can
help to figure it out?

BR
anderson

Reply via email to