Skip to content
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

LogService: Make getLevel() more robust against ClassNotFoundException #411

Merged
merged 2 commits into from
Dec 9, 2020

Conversation

maarzt
Copy link
Contributor

@maarzt maarzt commented Dec 3, 2020

This should fix issue: #410

Previously: If fine grained log levels are set LogService would call CallingClassUtils.getCallingClass() to find the appropriate log level for this class. This process would fail if the calling class could not be loaded with the default class loader. A IllegalStateException would be thrown instead.

This PR fixes this behavior. The class name is used rather the the class object. This avoids using Class.forName(...) if possible. But Class.forName(...) is still used to check for the presence of the IgnoreAsCallingClass annotation.

Copy link
Member

@ctrueden ctrueden left a comment

Choose a reason for hiding this comment

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

@maarzt Thanks a bunch for working on this! Especially while on leave. Much appreciated.

I just have one request, to avoid using Class.forName in favor of SciJava's unified class loading access method.

src/main/java/org/scijava/log/CallingClassUtils.java Outdated Show resolved Hide resolved
Class.forName() will fail if the threads class loader is not set.
@ctrueden ctrueden merged commit afe795a into master Dec 9, 2020
@ctrueden ctrueden deleted the fix-logservice-calling-class branch December 9, 2020 15:19
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