Saad Benbouzid created CXF-5719:
-----------------------------------

             Summary: NoSuchElementException in ClientFaultConverter when stack 
trace message contains * or #
                 Key: CXF-5719
                 URL: https://issues.apache.org/jira/browse/CXF-5719
             Project: CXF
          Issue Type: Bug
          Components: Core
    Affects Versions: 3.0.0-milestone1, 2.7.7, 2.6.10
            Reporter: Saad Benbouzid


Following stack trace shows up whenever there is a # or a * character in one of 
the 'Caused By:' clause.

{code}
Caused by: java.util.NoSuchElementException
        at java.util.StringTokenizer.nextToken(StringTokenizer.java:349)
        at 
org.apache.cxf.interceptor.ClientFaultConverter.parseStackTrackLine(ClientFaultConverter.java:287)
        at 
org.apache.cxf.interceptor.ClientFaultConverter.getCause(ClientFaultConverter.java:278)
        at 
org.apache.cxf.interceptor.ClientFaultConverter.setStackTrace(ClientFaultConverter.java:246)
        at 
org.apache.cxf.interceptor.ClientFaultConverter.handleMessage(ClientFaultConverter.java:79)
        at 
org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:272)
        at 
org.apache.cxf.interceptor.AbstractFaultChainInitiatorObserver.onMessage(AbstractFaultChainInitiatorObserver.java:113)
        at 
org.apache.cxf.binding.soap.interceptor.CheckFaultInterceptor.handleMessage(CheckFaultInterceptor.java:69)
        at 
org.apache.cxf.binding.soap.interceptor.CheckFaultInterceptor.handleMessage(CheckFaultInterceptor.java:34)
        at 
org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:272)
        at org.apache.cxf.endpoint.ClientImpl.onMessage(ClientImpl.java:845)
{code}

For example : 
{code}
org.springframework.jdbc.UncategorizedSQLException: Error setting null for 
parameter #1 with JdbcType OTHER . Try setting a different JdbcType for this 
parameter or a different jdbcTypeForNull configuration property. Cause: 
java.sql.SQLException: Type de colonne non valide: 1111
; uncategorized SQLException for SQL []; SQL state [99999]; error code [17004]; 
Type de colonne non valide: 1111; nested exception is java.sql.SQLException: 
Type de colonne non valide: 1111
        at 
org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:83)
        at 
org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:80)
        at 
org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:80)
        at 
org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:73)
        at 
org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:371)
        at com.sun.proxy.$Proxy74.selectOne(Unknown Source)
{code}

Because it considers the # (sharp) character as a delimiter.
That means actual CSF stack trace deserialization does not work for any 'Caused 
By' clause with a sharp (#) or a star character (#)... which is really 
unpleasant for customization (see stack trace Apache MyBatis stack trace 
example above).

Please avoid *StringTokenizer* splitting in favor of a  *String.split(...)* or 
a plain old iterator. Because *StringTokenizer* considers not only 
*Message.EXCEPTION_CAUSE_SUFFIX* as a delimiter, but also each character in it, 
which are sharp # and star *.

{quote}
StringTokenizer is a legacy class that is retained for compatibility reasons 
although its use is discouraged in new code. It is recommended that anyone 
seeking this functionality use the split method of String or the 
java.util.regex package instead.
{quote}

{color:red}
*org.apache.cxf.interceptor.ClientFaultConverter._setStackTrace_*
{color}
also see CXF-5231




--
This message was sent by Atlassian JIRA
(v6.2#6252)

Reply via email to