You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@camel.apache.org by "Claus Ibsen (JIRA)" <ji...@apache.org> on 2014/02/28 08:37:23 UTC

[jira] [Resolved] (CAMEL-7241) ByteBuffer to String conversion uses buffer capacity not limit

     [ https://issues.apache.org/jira/browse/CAMEL-7241?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Claus Ibsen resolved CAMEL-7241.
--------------------------------

    Resolution: Fixed

> ByteBuffer to String conversion uses buffer capacity not limit
> --------------------------------------------------------------
>
>                 Key: CAMEL-7241
>                 URL: https://issues.apache.org/jira/browse/CAMEL-7241
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-core
>    Affects Versions: 2.12.3
>            Reporter: Aaron Whiteside
>            Assignee: Willem Jiang
>             Fix For: 2.12.4, 2.13.0, 2.11.5
>
>   Original Estimate: 1h
>  Remaining Estimate: 1h
>
> Camel's conversion logic for ByteBuffer's to String's has a bug where camel uses a ByteBuffers capacity() instead of it's limit().
> If you allocate a large byte buffer and only partially fill it with data, and use camel to convert this into a string, camel tries to convert all the bytes, even the non-used ones.
> This unit test reproduces this bug.
> {code}
>     @Test
>     public void testByteBufferToStringConversion()
>     {
>         String str = "123456789";
>         ByteBuffer buffer = ByteBuffer.allocate( 16 );
>         buffer.put( str.getBytes() );
>         Exchange exchange = new DefaultExchange( context() );
>         exchange.getIn().setBody( buffer );
>         assertEquals( str, exchange.getIn().getBody( String.class ) );
>     }
> {code}



--
This message was sent by Atlassian JIRA
(v6.1.5#6160)