cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
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
Date Wed, 04 Jun 2014 18:59:04 GMT
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 <noo.blaster@gmail.com>
Authored: Fri May 23 15:05:12 2014 +0200
Committer: Daniel Kulp <dkulp@apache.org>
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<StackTraceElement> stackTraceList = new ArrayList<StackTraceElement>();
         if (!StringUtils.isEmpty(ss)) {
-            StringTokenizer st = new StringTokenizer(ss, Message.EXCEPTION_CAUSE_SUFFIX);
-            while (st.hasMoreTokens()) {
-                String oneLine = st.nextToken();
+            Iterator<String> 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<String> 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<StackTraceElement> stackTraceList = new ArrayList<StackTraceElement>();
-        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;
             }


Mime
View raw message