CliClient does not log root cause exception when catch it from 
executeCLIStatement
----------------------------------------------------------------------------------

                 Key: CASSANDRA-2746
                 URL: https://issues.apache.org/jira/browse/CASSANDRA-2746
             Project: Cassandra
          Issue Type: Bug
            Reporter: Jackson Chung


When executing a statement from the cassandra-cli (with --debug) , if an 
exception is thrown from one of the cases in side the executeCLIStatement 
method, the root cause is swallowed. For specific case such as the 
InvalidRequestException or the SchemaDisagreementException, just the message 
itself maybe enough, but for the general Exception case, without the root 
cause, it could be difficult to debug the issue. 

For example, we have seen exception like:
{noformat}
null
java.lang.RuntimeException
at org.apache.cassandra.cli.CliClient.executeCLIStatement(CliClient.java:209)
at org.apache.cassandra.cli.CliMain.processStatement(CliMain.java:223)
at org.apache.cassandra.cli.CliMain.main(CliMain.java:351)
{noformat}

the null there would most likely indicate this is a NPE (though it could still 
be any Exception with null message). By adding a initCause to the caught 
exception, we could see the root cause, eg:

{noformat}
null
java.lang.RuntimeException
        at 
org.apache.cassandra.cli.CliClient.executeCLIStatement(CliClient.java:212)
        at org.apache.cassandra.cli.CliMain.processStatement(CliMain.java:223)
        at org.apache.cassandra.cli.CliMain.main(CliMain.java:351)
Caused by: java.lang.NullPointerException
        at 
org.apache.cassandra.cli.CliClient.describeKeySpace(CliClient.java:1336)
        at 
org.apache.cassandra.cli.CliClient.executeShowKeySpaces(CliClient.java:1166)
        at 
org.apache.cassandra.cli.CliClient.executeCLIStatement(CliClient.java:170)
        ... 2 more
{noformat}

submitting a patch here that would add the initCause to all caught exceptions 
here. But the most important one is the general Exception case.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to