Hi,

While testing Camel Mina 2 component, we noticed that big message
payload received via UDP endpoint was always truncated to 2048 bytes
at Mina2Consumer. We did some investigation and found out that this
problem was caused by the default UDP codec. Comparing default UDP
codec in Mina 2 with its counterpart in Mina 2, the different behavior
might be caused by the replacement of ByteBuffer with IoBuffer and
setting auto expand value to true (even though this may seem counter
intuitive).

Camel - Mina (MinaUdpProtocolCodecFactory):
...
            private ByteBuffer toByteBuffer(Object message, CharsetEncoder 
encoder)
                throws CharacterCodingException, 
NoTypeConversionAvailableException {
                String value =
context.getTypeConverter().convertTo(String.class, message);
                if (value != null) {
                    ByteBuffer answer =
ByteBuffer.allocate(value.length()).setAutoExpand(false);
                    answer.putString(value, encoder);
                    return answer;
                }
        
                // failback to use a byte buffer converter
                return
context.getTypeConverter().mandatoryConvertTo(ByteBuffer.class,
message);
            }

Camel - Mina 2 (Mina2UdpProtocolCodecFactory):
...
    private IoBuffer toIoBuffer(Object message, CharsetEncoder encoder)
                throws CharacterCodingException, 
NoTypeConversionAvailableException {
                String value =
context.getTypeConverter().convertTo(String.class, message);
                if (value != null) {
                    IoBuffer answer =
IoBuffer.allocate(value.length()).setAutoExpand(true);
                    answer.putString(value, encoder);
                    return answer;
                }
        
                // failback to use a byte buffer converter
                return
context.getTypeConverter().mandatoryConvertTo(IoBuffer.class,
message);
            }


We would like to know if this issue is also reproducible by others.
Camel version we use for this testing is 2.10.2.

Regards,
Mike

Reply via email to