未验证 提交 6c7339af 编写于 作者: J Jesse Glick 提交者: GitHub

Merge pull request #4419 from jglick/loadResource-JENKINS-60644

[JENKINS-60641, JENKINS-60644] incorrectly converted AntClassLoader.loadResource to a Java 5 for-loop
......@@ -744,12 +744,13 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener {
private InputStream loadResource(String name) {
// we need to search the components of the path to see if we can
// find the class we want.
InputStream stream = null;
for (File pathComponent : pathComponents) {
stream = getResourceStream(pathComponent, name);
InputStream stream = getResourceStream(pathComponent, name);
if (stream != null) {
return stream;
}
}
return stream;
return null;
}
/**
......
/*
* The MIT License
*
* Copyright 2020 CloudBees, Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package jenkins.util;
import org.junit.ClassRule;
import org.junit.Test;
import static org.junit.Assert.*;
import org.junit.Rule;
import org.jvnet.hudson.test.BuildWatcher;
import org.jvnet.hudson.test.Issue;
import org.jvnet.hudson.test.JenkinsRule;
import org.jvnet.hudson.test.recipes.WithPlugin;
public class AntClassLoaderTest {
@Rule
public JenkinsRule r = new JenkinsRule();
@Issue("JENKINS-60644")
@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"));
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册