-
-
Notifications
You must be signed in to change notification settings - Fork 8.7k
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
[JENKINS-60641, JENKINS-60644] incorrectly converted AntClassLoader.loadResource to a Java 5 for-loop #4419
Conversation
… Java 5 for-loop.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for catching! I was unable to notice it in code reviews even after pin-pointing the pull request. Will need an out=of order release if @kohsuke is available
@jglick I guess the same fix is needed in the new |
No, that one looks fine to me, since it is checking for a null result in each iteration. The problem here in |
Without fix, Jenkins startup fails: java.lang.NullPointerException at java.io.Reader.<init>(Reader.java:78) at java.io.InputStreamReader.<init>(InputStreamReader.java:113) at org.apache.commons.io.IOUtils.copy(IOUtils.java:2440) at org.apache.commons.io.IOUtils.toString(IOUtils.java:1084) at io.jenkins.plugins.loads_resource.Main.stuff(Main.java:36)
@WithPlugin("loads-resource.jpi") | ||
@Test | ||
public void loadsResource() throws Exception { | ||
assertNotNull(r.jenkins.pluginManager.getPlugin("loads-resource").classLoader.getResourceAsStream("io/jenkins/plugins/loads_resource/stuff")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is probably the only case where PluginManager.getPlugin("loads-resource")
actually works in JTH :(
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, it would always work for loaded plugins, but normally the classLoader
would just be AppClassLoader
. You need to go out of your way to test the real plugin loaders.
} | ||
return stream; | ||
return null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For those who like this sort of thing:
return pathComponents.stream().map(pc -> getResourceStream(pc, name)).filter(Objects::nonNull).findFirst().orElse(null);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't
JENKINS-60644
Corrects a mistake in #4254 which broke some plugins.
Proposed changelog entries
script-security
andactive-directory
plugins.