Uploaded image for project: 'Cassandra'
  1. Cassandra
  2. CASSANDRA-15754

YamlConfigurationLoader swallows a real exception and exposes a misleading exception message

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Triage Needed
    • Priority: Normal
    • Resolution: Unresolved
    • Fix Version/s: None
    • Component/s: Local/Config
    • Labels:
      None
    • Platform:
      All
    • Impacts:
      None

      Description

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

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

      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:

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

      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:

      throw new ConfigurationException(msg, e)
      

      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.

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              tashoyan Arseniy Tashoyan
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:

                Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0h
                0h
                Logged:
                Time Spent - 20m
                20m