Arseniy Tashoyan created CASSANDRA-15754:
--------------------------------------------

             Summary: YamlConfigurationLoader swallows a real exception and 
exposes a misleading exception message
                 Key: CASSANDRA-15754
                 URL: https://issues.apache.org/jira/browse/CASSANDRA-15754
             Project: Cassandra
          Issue Type: Bug
          Components: Local/Config
            Reporter: Arseniy Tashoyan


Method YamlConfigurationLoader.loadConfig(URL) parses a YAML config file:

{code:java}
try {
  ...
  Config result = loadConfig(yaml, configBytes);
  ...
}
catch (YAMLException e) {
  throw new ConfigurationException("Invalid yaml: " + url + 
SystemUtils.LINE_SEPARATOR + " Error: " + e.getMessage(), false);
}
{code}

In the catch block, the real cause is dropped and a misleading message "Invalid 
yaml" is given. Instead in my case I have a cause:

{code:none}
java.lang.NoSuchMethodError: 
com.google.common.collect.Sets.newConcurrentHashSet()Ljava/util/Set;
{code}

This is caused by an incompatible Guava version in classpath. It was impossible 
to figure out the real root cause without debugging.

One possible fix is to include the caught exception (YAMLException e) in the 
cause of the thrown exception:

{code:java}
throw new ConfigurationException(msg, e)
{code}

The 'msg' should be changed because it is not necessarily "Invalid yaml".

Another possible fix is to not catch exception here - just let the root cause 
exception propagate to the caller.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to