Skip to content

Include the cause when a plugin fails to be instantiated #1471

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

stevedlawrence
Copy link
Member

If a UDF, charset, or layer plugin fails to be instantiated because and exception is thrown when loading, then we get a pretty helpful message, like:

Named service XYZ failed to load. Cause: Provider XYZ could not be instantiated

This provides no useful information as to the underlying cause why the provider could not be instantiated, so is very difficult to track down and fix.

When this kind of error occurs, Java throws a ServiceConfigurationError exception and includes the underlying exception as the cause. This changes the logging message so we include the cause if one exists. This should make it a little easier for users to figure out why their plugin failed to load.

DAFFODIL-2989

Copy link
Contributor

@olabusayoT olabusayoT left a comment

Choose a reason for hiding this comment

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

+1

Copy link
Contributor

@mbeckerle mbeckerle left a comment

Choose a reason for hiding this comment

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

+1

@stevedlawrence
Copy link
Member Author

Actually, I think we need something better than this. The issue we ran into that required this change was actually when a charset plugin threw a NullPointerException. In this case, the core exception was nested 3 exceptions deep, so looking at just the first cause wasn't enough. Additionally, even if we traversed to the bottom cause, the NullPointerException message doesn't help to let us know where the exception actually occurred, we really need the stack trace.

So I've changed this so that it outputs the original message at the warning level and outputs the full stacktrack at the debug level. This maintains the current behavior of a simple warning that can be easily ignored, but allows devs to get the full stack trace if needed. Does this approach seem reasonable? Another option is to just always output the stack trace, but it can be pretty verbose and in some cases it might not actually matter.

@mbeckerle
Copy link
Contributor

This issue of a cause in side a cause inside another cause, and which one you want a stacktrace from, is quite problematic.
If you tried to create a message from the whole chain, and even gathering up a few stack frames to highlight from each stacktrace, well in scala code often you need quite a bit of stack to get from somewhere deep in the collections library back out to a stack frame of some relevance to the issue.

If the message says "Stack trace available in debug mode. See xyzzy." and there are instructions about how to enable debug somewhere, then that's about best we can do.

@stevedlawrence stevedlawrence force-pushed the daffodil-2989-service-configuration-error-cause branch from 9fccaf9 to b295f35 Compare April 8, 2025 13:21
If a UDF, charset, or layer plugin fails to be instantiated because and
exception is thrown when loading, then we get a pretty helpful message,
like:

  Named service XYZ failed to load. Cause: Provider XYZ could not be instantiated

This provides no useful information as to the underlying cause why the
provider could not be instantiated, so is very difficult to track down
and fix.

When this kind of error occurs, Java throws a ServiceConfigurationError
exception and includes the underlying exception as the cause. This
changes the logging message so we include the cause if one exists. This
should make it a little easier for users to figure out why their plugin
failed to load.

DAFFODIL-2989
@stevedlawrence stevedlawrence force-pushed the daffodil-2989-service-configuration-error-cause branch from b295f35 to e0bb3b6 Compare April 8, 2025 13:25
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.

3 participants