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

Add handlings for classes which are available in Thread.currentThread().getContextClassLoader() #785

Merged
merged 1 commit into from
May 8, 2015

Conversation

drcrallen
Copy link
Contributor

druid.io jumps through some nasty hoops to try and isolate hadoop classes. Part of this is NOT including the hadoop jars in the system classpath, but creating a separate URL class loader which isolates the hadoop class handling. Unfortunately this causes getDeclaredMethods() to puke and die since the original cls or _class (loaded through the system classloader) may have methods which use some of the hadoop classes, and the context class loader is not taken into account when resolution of the declared methods proceeds.

This proposed patch simply watches for the failure case, and tries to load the class from the context class loader instead.

Another potential solution would be to load the cls or _class from the context class loader way before it reaches this point, but I am not fluent enough in jackson-databind to make such a change.

@cowtowncoder
Copy link
Member

Ok, sounds reasonable. Class loading/handling should probably be improved outside of this place as you suggest, but I don't think I know enough to figure out how, or to test its functioning with a good set up. So I think change would work.

One minor problem is that ex.addSuppressed(e); can't be used, if I read JDK javadocs correctly. It was added in 1.7, and Jackson still has 1.6 as the base. We will probably bump baseline for some 2.x version, so maybe leaving that commented out for now, and adding a separate issue for later retrofit would make sense.

Anyway, I can change that, or if you want you can change it in patch.

But before merge, one OSS process thing: have I already asked for an CLA? If not, we need this:

https://github.com/FasterXML/jackson/blob/master/contributor-agreement.pdf

filled, scanned & emailed to info at fasterxml dot com, and I can merge it. And any and all future patches for Jackson components too, it's just a one-time thing.

Thank you again for the contribution, looking forward to merging it!

@drcrallen drcrallen force-pushed the jackson-databind-2.4.4-mmx branch from b1ed170 to 3858853 Compare May 7, 2015 20:35
@drcrallen
Copy link
Contributor Author

@cowtowncoder : I'll get the CLA signed soon.

cowtowncoder added a commit that referenced this pull request May 8, 2015
Add handlings for classes which are available in `Thread.currentThread().getContextClassLoader()`
@cowtowncoder cowtowncoder merged commit afb688a into FasterXML:2.4 May 8, 2015
@cowtowncoder
Copy link
Member

Merged. Not sure if there will be new 2.4 releases, but since patch is there, maybe a micro-release (2.4.6.1) is possible. And 2.5.4 will have the fix similarly.

@cowtowncoder cowtowncoder added this to the 2.5.4 milestone May 8, 2015
@drcrallen drcrallen deleted the jackson-databind-2.4.4-mmx branch February 4, 2016 18:12
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.

None yet

2 participants