Skip to content

Fix NPE at getClass().getClassLoader() #1345

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

Closed
wants to merge 1 commit into from

Conversation

isopov
Copy link

@isopov isopov commented Feb 4, 2017

I've tried to play with async-http-client in jcstress, but AFAIU it uses bootstrap classloader and creating async-http-client fails with NPE.

@slandelle
Copy link
Contributor

Hi,

I agree with the issue, but your fix is broken. We can't live without a loaded config.

A proper fix would be to try ContextClassLoader, Class' ClassLoader and SystemClassLoader until we find a non null one, and then use it to call getResourceAsStream.

Could you please fix properly?

Cheers

slandelle added a commit that referenced this pull request Feb 6, 2017
Motivation:

Class::getClassLoader can return null if the Class was loaded by the
bootstrap ClassLoader.

Modification:

Scan all non null ClassLoaders.

Result:

No more NPE when class was loaded by the bootstrap ClassLoader
@slandelle slandelle closed this in 5af18b4 Feb 6, 2017
@slandelle
Copy link
Contributor

@isopov Could you please check if the fix in 6573e24 works for you?

@slandelle slandelle added this to the 2.0.29 milestone Feb 6, 2017
@slandelle slandelle self-assigned this Feb 6, 2017
@isopov
Copy link
Author

isopov commented Feb 15, 2017

Sorry, I was on vacation - that fix works well for me, thanks!

@slandelle
Copy link
Contributor

Great, thanks for your feedback!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants