-
Bug
-
Resolution: Fixed
-
Major
-
None
-
-
2.422
On startup, Jenkins list plugins using File.listFiles without any ordering. At https://github.com/jenkinsci/jenkins/blob/jenkins-2.421/core/src/main/java/hudson/init/InitStrategy.java#L63. Java does not guarantee any specific order https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/io/File.html#listFiles().
There is then a topoligical sort to guarantee that dependencies are loaded first. But because the listed plugin files are in a different order from the start, the order may be different depending on the environment and hardly reproducible.
****
There are cases when this matter. In particular when a plugin bundles jars that conflicts with another plugin and when order in the class loading matter.
As a concrete example, we detected that the order was a problem in an environment where the SAML plugin was bundling woodstox-core 6.2.7 whereas other plugins has woodstox 6.3.1 available from the jackson2-api plugin.
- If SAML is loaded first, plugins that would lookup an XMLInputFactory through the ServiceLoader - usually through the method javax.xml.stream.XMLInputFactory.newInstance would experience a java.lang.ClassNotFoundException: org.codehaus.stax2.XMLInputFactory2
- If Jackson2-API is loaded first, plugins that used the {{}} would be fine.
****
The plugin loading order should be deterministic to at least help reproduce such kind of issues and identify culprit faster.
- links to