[FIXED JENKINS-37538] Set the context class loader to a neutral value inside step executions #50
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
JENKINS-37538
Amends #42. Probably fixes a bug which I have not yet been able to reproduce. My working hypothesis is that with certain class loaders as
Thread.contextClassLoader
,SAXParserFactory.newInstance()
fails for reasons TBD but probably related to a mismatch between theClassLoader
defining some copy ofSAXParserFactory
and one defining a copy oforg.apache.xerces.jaxp.SAXParserFactoryImpl
, due to a design flaw inServiceLoader
.My first thought was to use
d.clazz.getClassLoader()
so that theStep
’s own plugin code would be available, but in the case ofartifactory
(cf. jfrog/jenkins-artifactory-plugin#30) this will delegate to the loader ofparameterized-trigger
which currently (reasons TBD) bundlesWEB-INF/lib/xercesImpl-2.9.1.jar
, so that is still possibly a problem. Instead I am taking the more conservative choice of the context loader in effect for most other plugin code in Jenkins, leaving the use ofGroovyClassLoader.InnerLoader
to code run directly from Pipeline script.@reviewbybees