Skip to content

MINOR: Fix use of ConfigException in AbstractConfig class#11349

Merged
tombentley merged 2 commits into
apache:trunkfrom
C0urante:patch-2
Sep 28, 2021
Merged

MINOR: Fix use of ConfigException in AbstractConfig class#11349
tombentley merged 2 commits into
apache:trunkfrom
C0urante:patch-2

Conversation

@C0urante

@C0urante C0urante commented Sep 21, 2021

Copy link
Copy Markdown
Contributor

The two-arg variant is intended to take a property name and value, not an exception message and a cause.

As-is, this leads to confusing log messages like:

org.apache.kafka.common.config.ConfigException: Invalid value java.lang.ClassNotFoundException: io.strimzi.kafka.KubernetesConfigMapConfigProvider for configuration Invalid config:io.strimzi.kafka.KubernetesConfigMapConfigProvider ClassNotFoundException exception occurred

Committer Checklist (excluded from commit message)

  • Verify design and implementation
  • Verify test coverage and CI build status
  • Verify documentation (including upgrade notes)

} catch (ClassNotFoundException e) {
log.error("ClassNotFoundException exception occurred: " + entry.getValue());
throw new ConfigException("Invalid config:" + entry.getValue() + " ClassNotFoundException exception occurred", e);
throw new ConfigException(providerClassProperty(entry.getKey()), entry.getValue(), "ClassNotFoundException exception occurred");

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if the class that's not found isn't the config provider but some dependency of it? Because the CNFE message isn't logged nor passed to the ConfigException this info would be lost.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point; I've updated the log line above to include the entire stack trace. It'd be nice if there were a variant of ConfigException that took in a cause argument but there is none at the moment and it's probably not worth it to add one just for this use case.

@tombentley

Copy link
Copy Markdown
Member

Failing test is unrelated.

@tombentley
tombentley merged commit 5a5c058 into apache:trunk Sep 28, 2021
@tombentley

Copy link
Copy Markdown
Member

Thanks @C0urante!

@C0urante
C0urante deleted the patch-2 branch November 30, 2021 17:11
xdgrulez pushed a commit to xdgrulez/kafka that referenced this pull request Dec 22, 2021
* Log full trace for class-not-found errors, improve accuracy of error messages

Reviewers: Tom Bentley <tbentley@redhat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants