Return-Path: X-Original-To: apmail-cxf-commits-archive@www.apache.org Delivered-To: apmail-cxf-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id C0EE510234 for ; Wed, 4 Jun 2014 18:59:03 +0000 (UTC) Received: (qmail 4039 invoked by uid 500); 4 Jun 2014 18:59:03 -0000 Delivered-To: apmail-cxf-commits-archive@cxf.apache.org Received: (qmail 3982 invoked by uid 500); 4 Jun 2014 18:59:03 -0000 Mailing-List: contact commits-help@cxf.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cxf.apache.org Delivered-To: mailing list commits@cxf.apache.org Received: (qmail 3975 invoked by uid 99); 4 Jun 2014 18:59:03 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 04 Jun 2014 18:59:03 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 66F2893F41A; Wed, 4 Jun 2014 18:59:03 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: dkulp@apache.org To: commits@cxf.apache.org Date: Wed, 04 Jun 2014 18:59:04 -0000 Message-Id: <2a87747adf574f91897dfbce68ec708d@git.apache.org> In-Reply-To: <79513dbd66bd4382893ee90d575beb91@git.apache.org> References: <79513dbd66bd4382893ee90d575beb91@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [2/2] git commit: fix CXF-5719 : remove wrong tokenizer usage, a bug occurring when exception message contains "#*#" still exists (but its not a cxf-core bug) This closes #5 fix CXF-5719 : remove wrong tokenizer usage, a bug occurring when exception message contains "#*#" still exists (but its not a cxf-core bug) This closes #5 Project: http://git-wip-us.apache.org/repos/asf/cxf/repo Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/3a6daf70 Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/3a6daf70 Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/3a6daf70 Branch: refs/heads/2.7.x-fixes Commit: 3a6daf70abc2b1fbddc009183bf2e794a4f869d0 Parents: 1a60a05 Author: neyb Authored: Fri May 23 15:05:12 2014 +0200 Committer: Daniel Kulp Committed: Wed Jun 4 14:57:58 2014 -0400 ---------------------------------------------------------------------- .../cxf/interceptor/ClientFaultConverter.java | 22 ++++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cxf/blob/3a6daf70/api/src/main/java/org/apache/cxf/interceptor/ClientFaultConverter.java ---------------------------------------------------------------------- diff --git a/api/src/main/java/org/apache/cxf/interceptor/ClientFaultConverter.java b/api/src/main/java/org/apache/cxf/interceptor/ClientFaultConverter.java index d9a4310..fcaab3d 100644 --- a/api/src/main/java/org/apache/cxf/interceptor/ClientFaultConverter.java +++ b/api/src/main/java/org/apache/cxf/interceptor/ClientFaultConverter.java @@ -22,12 +22,15 @@ import java.lang.reflect.Constructor; import java.lang.reflect.Field; import java.lang.reflect.Method; import java.util.ArrayList; +import java.util.Arrays; import java.util.HashMap; +import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.StringTokenizer; import java.util.logging.Level; import java.util.logging.Logger; +import java.util.regex.Pattern; import javax.xml.namespace.QName; import javax.xml.stream.XMLStreamException; @@ -36,7 +39,6 @@ import javax.xml.xpath.XPathConstants; import org.w3c.dom.Element; import org.w3c.dom.Node; - import org.apache.cxf.common.logging.LogUtils; import org.apache.cxf.common.util.ReflectionUtil; import org.apache.cxf.common.util.StringUtils; @@ -59,6 +61,8 @@ import org.apache.cxf.staxutils.W3CDOMStreamReader; */ public class ClientFaultConverter extends AbstractInDatabindingInterceptor { public static final String DISABLE_FAULT_MAPPING = "disable-fault-mapping"; + public static final Pattern CAUSE_SUFFIX_SPLITTER + = Pattern.compile(Message.EXCEPTION_CAUSE_SUFFIX, Pattern.LITERAL | Pattern.MULTILINE); private static final Logger LOG = LogUtils.getLogger(ClientFaultConverter.class); public ClientFaultConverter() { @@ -239,11 +243,11 @@ public class ClientFaultConverter extends AbstractInDatabindingInterceptor { XPathConstants.STRING); List stackTraceList = new ArrayList(); if (!StringUtils.isEmpty(ss)) { - StringTokenizer st = new StringTokenizer(ss, Message.EXCEPTION_CAUSE_SUFFIX); - while (st.hasMoreTokens()) { - String oneLine = st.nextToken(); + Iterator linesIterator = Arrays.asList(CAUSE_SUFFIX_SPLITTER.split(ss)).iterator(); + while (linesIterator.hasNext()) { + String oneLine = linesIterator.next(); if (oneLine.startsWith("Caused by:")) { - cause = getCause(st, oneLine); + cause = getCause(linesIterator, oneLine); break; } stackTraceList.add(parseStackTrackLine(oneLine)); @@ -263,15 +267,15 @@ public class ClientFaultConverter extends AbstractInDatabindingInterceptor { } // recursively parse the causes and instantiate corresponding throwables - private Throwable getCause(StringTokenizer st, String firstLine) { + private Throwable getCause(Iterator linesIterator, String firstLine) { // The actual exception class of the cause might be unavailable at the // client -> use a standard throwable to represent the cause. Throwable res = new Throwable(firstLine.substring(firstLine.indexOf(":") + 2)); List stackTraceList = new ArrayList(); - while (st.hasMoreTokens()) { - String oneLine = st.nextToken(); + while (linesIterator.hasNext()) { + String oneLine = linesIterator.next(); if (oneLine.startsWith("Caused by:")) { - Throwable nestedCause = getCause(st, oneLine); + Throwable nestedCause = getCause(linesIterator, oneLine); res.initCause(nestedCause); break; }