Return-Path: X-Original-To: apmail-camel-issues-archive@minotaur.apache.org Delivered-To: apmail-camel-issues-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 6CE5810EE0 for ; Wed, 26 Feb 2014 02:37:28 +0000 (UTC) Received: (qmail 21346 invoked by uid 500); 26 Feb 2014 02:37:26 -0000 Delivered-To: apmail-camel-issues-archive@camel.apache.org Received: (qmail 21169 invoked by uid 500); 26 Feb 2014 02:37:25 -0000 Mailing-List: contact issues-help@camel.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@camel.apache.org Delivered-To: mailing list issues@camel.apache.org Received: (qmail 21062 invoked by uid 99); 26 Feb 2014 02:37:23 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 26 Feb 2014 02:37:23 +0000 Date: Wed, 26 Feb 2014 02:37:23 +0000 (UTC) From: "Willem Jiang (JIRA)" To: issues@camel.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (CAMEL-7241) ByteBuffer to String conversion uses buffer capacity not limit MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/CAMEL-7241?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13912445#comment-13912445 ] Willem Jiang commented on CAMEL-7241: ------------------------------------- Applied the patch into camel master, camel-2.12.x and camel-2.11.x branches. > 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)