Return-Path: X-Original-To: apmail-camel-dev-archive@www.apache.org Delivered-To: apmail-camel-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id C69A017F55 for ; Sun, 28 Sep 2014 08:30:58 +0000 (UTC) Received: (qmail 16435 invoked by uid 500); 28 Sep 2014 08:30:58 -0000 Delivered-To: apmail-camel-dev-archive@camel.apache.org Received: (qmail 16380 invoked by uid 500); 28 Sep 2014 08:30:58 -0000 Mailing-List: contact dev-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 dev@camel.apache.org Received: (qmail 16367 invoked by uid 99); 28 Sep 2014 08:30:58 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 28 Sep 2014 08:30:58 +0000 X-ASF-Spam-Status: No, hits=0.3 required=5.0 tests=FREEMAIL_REPLY,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of willem.jiang@gmail.com designates 209.85.192.175 as permitted sender) Received: from [209.85.192.175] (HELO mail-pd0-f175.google.com) (209.85.192.175) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 28 Sep 2014 08:30:32 +0000 Received: by mail-pd0-f175.google.com with SMTP id v10so14171608pde.34 for ; Sun, 28 Sep 2014 01:30:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:message-id:in-reply-to:references:subject:mime-version :content-type:content-transfer-encoding:content-disposition; bh=xImblIKMuOfpkH8YCHzCYLLdH1WQG+WMXq1i5PwtTwU=; b=xILoPax+UsIQ9/zRLDgrFuW+SRxz6QbogMt3drHzBo9taE7QviCu8Dnpdm3KBRHozc YhgktbPnYh6NytuduD2qm+eL2uPs7ZcOl84W+UHdkClJ1w8E/MkxW1jV4YRCLlACtBGA IHF8u0+RImQyrTbe4qYYpUddr6+FpaczOSEONlOxfZ0P6mjqV7F/VbNvMO9QjtsWA4oW Gh6R3CxwfCicf7Z8PPg+l76k+wK+GElW7reUpoT8ZURbabKd49j+7KOZSxzZGKjlz+cz j+AaN6ELVx6BjMygWLpgWO8RPcML/eR/2BMVFtF4VNKU9OQICLsboLXhEBA9oOfLt+C0 5bAw== X-Received: by 10.69.26.100 with SMTP id ix4mr48759299pbd.29.1411893030358; Sun, 28 Sep 2014 01:30:30 -0700 (PDT) Received: from dhcp-17-73.nay.redhat.com ([203.114.244.88]) by mx.google.com with ESMTPSA id rl4sm9198125pbc.69.2014.09.28.01.30.28 for (version=TLSv1.2 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 28 Sep 2014 01:30:29 -0700 (PDT) Date: Sun, 28 Sep 2014 16:30:20 +0800 From: Willem Jiang To: dev@camel.apache.org Message-ID: In-Reply-To: References: <02db013979cf4ed2a7dcf30e29e7afde@git.apache.org> Subject: Re: [1/3] git commit: CAMEL-7876 ensure GroupIterator uses the exchange's CHARSET_NAME property X-Mailer: Airmail (247) MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline X-Virus-Checked: Checked by ClamAV on apache.org Hi Tom, The PR was merged, you can close it now. Regards, -- =20 Willem Jiang Red Hat, Inc. Web: http://www.redhat.com Blog: http://willemjiang.blogspot.com (English) http://jnn.iteye.com (Chinese) Twitter: willemjiang =20 Weibo: =E5=A7=9C=E5=AE=81willem On September 28, 2014 at 3:34:21 PM, Tom Ellis (tellisnz=40gmail.com) wro= te: > Hi Guys, > =20 > I'm a bit new to the pull request contributions - was the request accep= ted > and I should close now, or is there something else to happen first=3F > =20 > On 28 September 2014 07:19, Willem Jiang wrote: > =20 > > Hi Claus, > > > > Thanks for pointing that out, I just committed a quick fix for it. > > > > Regards, > > > > -- > > Willem Jiang > > > > Red Hat, Inc. > > Web: http://www.redhat.com > > Blog: http://willemjiang.blogspot.com (English) > > http://jnn.iteye.com (Chinese) > > Twitter: willemjiang > > Weibo: =E5=A7=9C=E5=AE=81willem > > > > > > > > On September 28, 2014 at 1:28:22 PM, Claus Ibsen (claus.ibsen=40gmail= .com) > > wrote: > > > Hi > > > > > > Please use the unicode number of the non Ascii chars in the source > > > code, eg =5CuNNNN instead of those A characters. > > > > > > On Sun, Sep 28, 2014 at 5:30 AM, wrote: > > > > Repository: camel > > > > Updated Branches: > > > > refs/heads/master bd06a4a5f -> c9e1bc87e > > > > > > > > > > > > CAMEL-7876 ensure GroupIterator uses the exchange's CHARSET=5FNAM= E > > property > > > > > > > > > > > > Project: http://git-wip-us.apache.org/repos/asf/camel/repo > > > > Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/80518= e29 > > > > Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/80518e29 > > > > Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/80518e29 > > > > > > > > Branch: refs/heads/master > > > > Commit: 80518e29d93745bcad341e5c02bef8a0e31ece61 > > > > Parents: bd06a4a > > > > Author: Tom Ellis > > > > Authored: Sat Sep 27 17:27:33 2014 +0100 > > > > Committer: Willem Jiang > > > > Committed: Sun Sep 28 11:17:55 2014 +0800 > > > > > > > > -----------------------------------------------------------------= ----- =20 > > > > .../apache/camel/builder/ExpressionBuilder.java =7C 2 +- > > > > .../org/apache/camel/util/GroupIterator.java =7C 14 ++++---- > > > > .../apache/camel/util/GroupIteratorTest.java =7C 35 +++++++++++++= ++++++- > > > > 3 files changed, 42 insertions(+), 9 deletions(-) > > > > -----------------------------------------------------------------= ----- =20 > > > > > > > > > > > > > > http://git-wip-us.apache.org/repos/asf/camel/blob/80518e29/camel-core= /src/main/java/org/apache/camel/builder/ExpressionBuilder.java =20 > > > > -----------------------------------------------------------------= ----- =20 > > > > diff --git > > a/camel-core/src/main/java/org/apache/camel/builder/ExpressionBuilder= .java =20 > > > > > b/camel-core/src/main/java/org/apache/camel/builder/ExpressionBuilder= .java =20 > > > > index 4473fe7..20f00b9 100644 > > > > --- > > a/camel-core/src/main/java/org/apache/camel/builder/ExpressionBuilder= .java =20 > > > > +++ > > b/camel-core/src/main/java/org/apache/camel/builder/ExpressionBuilder= .java =20 > > > > =40=40 -1294,7 +1294,7 =40=40 public final class ExpressionBuilde= r =7B > > > > // evaluate expression as iterator > > > > Iterator it =3D expression.evaluate(exchange, Iterator.class); > > > > ObjectHelper.notNull(it, =22expression: =22 + expression + =22 ev= aluated on > > =22 + exchange > > > + =22 must return an java.util.Iterator=22); > > > > - return new GroupIterator(exchange.getContext(), it, token, grou= p); > > > > + return new GroupIterator(exchange, it, token, group); > > > > =7D > > > > > > > > =40Override > > > > > > > > > > http://git-wip-us.apache.org/repos/asf/camel/blob/80518e29/camel-core= /src/main/java/org/apache/camel/util/GroupIterator.java =20 > > > > -----------------------------------------------------------------= ----- =20 > > > > diff --git > > a/camel-core/src/main/java/org/apache/camel/util/GroupIterator.java > > > b/camel-core/src/main/java/org/apache/camel/util/GroupIterator.java= > > > > index 158dbed..4b6f9ad 100644 > > > > --- a/camel-core/src/main/java/org/apache/camel/util/GroupIterato= r.java =20 > > > > +++ b/camel-core/src/main/java/org/apache/camel/util/GroupIterato= r.java =20 > > > > =40=40 -23,7 +23,7 =40=40 import java.io.InputStream; > > > > import java.util.Iterator; > > > > import java.util.Scanner; > > > > > > > > -import org.apache.camel.CamelContext; > > > > +import org.apache.camel.Exchange; > > > > import org.apache.camel.NoTypeConversionAvailableException; > > > > > > > > /** > > > > =40=40 -37,7 +37,7 =40=40 import > > org.apache.camel.NoTypeConversionAvailableException; > > > > */ > > > > public final class GroupIterator implements Iterator, Closeable =7B= > > > > > > > > - private final CamelContext camelContext; > > > > + private final Exchange exchange; > > > > private final Iterator it; > > > > private final String token; > > > > private final int group; > > > > =40=40 -53,8 +53,8 =40=40 public final class GroupIterator implem= ents Iterator, > > > Closeable =7B > > > > * =40param group number of parts to group together > > > > * =40throws IllegalArgumentException is thrown if group is not a > > positive number > > > > */ > > > > - public GroupIterator(CamelContext camelContext, Iterator it, St= ring > > token, > > > int group) =7B > > > > - this.camelContext =3D camelContext; > > > > + public GroupIterator(Exchange exchange, Iterator it, String tok= en, > > int group) > > > =7B > > > > + this.exchange =3D exchange; > > > > this.it =3D it; > > > > this.token =3D token; > > > > this.group =3D group; > > > > =40=40 -130,15 +130,15 =40=40 public final class GroupIterator im= plements > > Iterator, > > > Closeable =7B > > > > bos.write(bytes); > > > > =7D else if (data =21=3D null) =7B > > > > // convert to input stream > > > > - InputStream is =3D > > camelContext.getTypeConverter().mandatoryConvertTo(InputStream.class,= > > > data); > > > > + InputStream is =3D > > exchange.getContext().getTypeConverter().mandatoryConvertTo(InputStre= am.class, =20 > > > data); > > > > IOHelper.copy(is, bos); > > > > =7D > > > > > > > > count++; > > > > =7D > > > > > > > > - // prepare and return answer as String > > > > - String answer =3D bos.toString(); > > > > + // prepare and return answer as String using exchange's charset= > > > > + String answer =3D bos.toString(IOHelper.getCharsetName(exchange= )); > > > > bos.reset(); > > > > return answer; > > > > =7D > > > > > > > > > > http://git-wip-us.apache.org/repos/asf/camel/blob/80518e29/camel-core= /src/test/java/org/apache/camel/util/GroupIteratorTest.java =20 > > > > -----------------------------------------------------------------= ----- =20 > > > > diff --git > > a/camel-core/src/test/java/org/apache/camel/util/GroupIteratorTest.ja= va =20 > > > b/camel-core/src/test/java/org/apache/camel/util/GroupIteratorTest.= java =20 > > > > index 4dbbac5..c5c3e33 100644 > > > > --- > > a/camel-core/src/test/java/org/apache/camel/util/GroupIteratorTest.ja= va =20 > > > > +++ > > b/camel-core/src/test/java/org/apache/camel/util/GroupIteratorTest.ja= va =20 > > > > =40=40 -16,11 +16,17 =40=40 > > > > */ > > > > package org.apache.camel.util; > > > > > > > > +import java.io.ByteArrayInputStream; > > > > +import java.nio.charset.Charset; > > > > +import java.nio.charset.StandardCharsets; > > > > +import java.util.Arrays; > > > > import java.util.Scanner; > > > > > > > > import org.apache.camel.CamelContext; > > > > +import org.apache.camel.Exchange; > > > > import org.apache.camel.TestSupport; > > > > import org.apache.camel.impl.DefaultCamelContext; > > > > +import org.apache.camel.impl.DefaultExchange; > > > > > > > > /** > > > > * > > > > =40=40 -28,12 +34,15 =40=40 import org.apache.camel.impl.DefaultC= amelContext; > > > > public class GroupIteratorTest extends TestSupport =7B > > > > > > > > private CamelContext context; > > > > + private Exchange exchange; > > > > > > > > =40Override > > > > public void setUp() throws Exception =7B > > > > super.setUp(); > > > > context =3D new DefaultCamelContext(); > > > > context.start(); > > > > + exchange =3D new DefaultExchange(context); > > > > + > > > > =7D > > > > > > > > =40Override > > > > =40=40 -47,7 +56,7 =40=40 public class GroupIteratorTest extends = TestSupport =7B > > > > Scanner scanner =3D new Scanner(s); > > > > scanner.useDelimiter(=22=5Cn=22); > > > > > > > > - GroupIterator gi =3D new GroupIterator(context, scanner, =22=5C= n=22, 3); > > > > + GroupIterator gi =3D new GroupIterator(exchange, scanner, =22=5C= n=22, 3); > > > > > > > > assertTrue(gi.hasNext()); > > > > assertEquals(=22ABC=5CnDE=46=5CnGHI=22, gi.next()); > > > > =40=40 -58,4 +67,28 =40=40 public class GroupIteratorTest extends= TestSupport =7B > > > > IOHelper.close(gi); > > > > =7D > > > > > > > > + public void testGroupIteratorWithDifferentEncoding=46romDefault= () > > throws Exception > > > =7B > > > > + if (Charset.defaultCharset() =3D=3D StandardCharsets.UT=46=5F8)= =7B > > > > + // can't think of test case where having default charset set to= > > UT=46-8 is affected > > > > + return; > > > > + =7D > > > > + > > > > + byte=5B=5D buf =3D =22=C3=82=C2=A31=5Cn=C3=82=C2=A32=5Cn=22.get= Bytes(StandardCharsets.UT=46=5F8); > > > > + > > > > + ByteArrayInputStream in =3D new ByteArrayInputStream(buf); > > > > + > > > > + Scanner scanner =3D new Scanner(in, > > StandardCharsets.UT=46=5F8.displayName()); > > > > + scanner.useDelimiter(=22=5Cn=22); > > > > + > > > > + exchange.setProperty(Exchange.CHARSET=5FNAME, > > StandardCharsets.UT=46=5F8.displayName()); > > > > + GroupIterator gi =3D new GroupIterator(exchange, scanner, =22=5C= n=22, 1); > > > > + > > > > + assertTrue(gi.hasNext()); > > > > + assertEquals(=22=C3=82=C2=A31=22, gi.next()); > > > > + assertEquals(=22=C3=82=C2=A32=22, gi.next()); > > > > + assert=46alse(gi.hasNext()); > > > > + > > > > + IOHelper.close(gi); > > > > + =7D > > > > + > > > > =7D > > > > > > > > > > > > > > > > -- > > > Claus Ibsen > > > ----------------- > > > Red Hat, Inc. > > > Email: cibsen=40redhat.com > > > Twitter: davsclaus > > > Blog: http://davsclaus.com > > > Author of Camel in Action: http://www.manning.com/ibsen > > > hawtio: http://hawt.io/ > > > fabric8: http://fabric8.io/ > > > > > > > > =20