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

Backporting for 2.452.1 #9204

Merged
merged 3 commits into from
Apr 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ THE SOFTWARE.
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-framework-bom</artifactId>
<version>5.3.33</version>
<version>5.3.34</version>
<type>pom</type>
<scope>import</scope>
</dependency>
Expand Down
3 changes: 3 additions & 0 deletions core/src/main/java/hudson/ExtensionFinder.java
Original file line number Diff line number Diff line change
Expand Up @@ -298,9 +298,11 @@ protected Injector resolve() {
}

private void refreshExtensionAnnotations() {
LOGGER.finer(() -> "refreshExtensionAnnotations()");
for (ExtensionComponent<GuiceExtensionAnnotation> ec : moduleFinder.find(GuiceExtensionAnnotation.class, Hudson.getInstance())) {
GuiceExtensionAnnotation gea = ec.getInstance();
extensionAnnotations.put(gea.annotationType, gea);
LOGGER.finer(() -> "found " + gea.getClass());
}
}

Expand Down Expand Up @@ -328,6 +330,7 @@ public Injector getContainer() {
*/
@Override
public synchronized ExtensionComponentSet refresh() throws ExtensionRefreshException {
LOGGER.finer(() -> "refresh()");
refreshExtensionAnnotations();
// figure out newly discovered sezpoz components
List<IndexItem<?, Object>> delta = new ArrayList<>();
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/java/hudson/slaves/JNLPLauncher.java
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ public String getTunnel() {
*/
@DataBoundSetter
public void setTunnel(String tunnel) {
this.tunnel = tunnel;
this.tunnel = Util.fixEmptyAndTrim(tunnel);
}

@Override
Expand Down
12 changes: 12 additions & 0 deletions core/src/main/java/jenkins/model/Jenkins.java
Original file line number Diff line number Diff line change
Expand Up @@ -2897,13 +2897,16 @@ public ExtensionList getExtensionList(String extensionType) throws ClassNotFound
*/
public void refreshExtensions() throws ExtensionRefreshException {
ExtensionList<ExtensionFinder> finders = getExtensionList(ExtensionFinder.class);
LOGGER.finer(() -> "refreshExtensions " + finders);
for (ExtensionFinder ef : finders) {
if (!ef.isRefreshable())
throw new ExtensionRefreshException(ef + " doesn't support refresh");
}

List<ExtensionComponentSet> fragments = new ArrayList<>();

for (ExtensionFinder ef : finders) {
LOGGER.finer(() -> "searching " + ef);
fragments.add(ef.refresh());
}
ExtensionComponentSet delta = ExtensionComponentSet.union(fragments).filtered();
Expand All @@ -2912,12 +2915,21 @@ public void refreshExtensions() throws ExtensionRefreshException {
List<ExtensionComponent<ExtensionFinder>> newFinders = new ArrayList<>(delta.find(ExtensionFinder.class));
while (!newFinders.isEmpty()) {
ExtensionFinder f = newFinders.remove(newFinders.size() - 1).getInstance();
LOGGER.finer(() -> "found new ExtensionFinder " + f);

ExtensionComponentSet ecs = ExtensionComponentSet.allOf(f).filtered();
newFinders.addAll(ecs.find(ExtensionFinder.class));
delta = ExtensionComponentSet.union(delta, ecs);
}

// we may not have found a new Extension finder but we may be using an extension finder that is extensible
// e.g. hudson.ExtensionFinder.GuiceFinder is extensible by GuiceExtensionAnnotation which is done by the variant plugin
// so lets give it one more chance.
for (ExtensionFinder ef : finders) {
LOGGER.finer(() -> "searching again in " + ef);
delta = ExtensionComponentSet.union(delta, ef.refresh().filtered());
}

for (ExtensionList el : extensionLists.values()) {
el.refresh(delta);
}
Expand Down
26 changes: 26 additions & 0 deletions test/src/test/java/hudson/slaves/JNLPLauncherTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.instanceOf;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.nullValue;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
Expand Down Expand Up @@ -112,6 +113,31 @@ public void testNoWorkDirMigration() {
jnlpLauncher.getWorkDirSettings().isDisabled());
}

@Issue("JENKINS-73011")
@SuppressWarnings("deprecation")
@Test
public void deprecatedFields() throws Exception {
var launcher = new JNLPLauncher();
launcher.setWebSocket(true);
launcher.setWorkDirSettings(new RemotingWorkDirSettings(false, null, "remoting2", false));
launcher.setTunnel("someproxy");
var agent = j.createSlave();
agent.setLauncher(launcher);
agent = j.configRoundtrip(agent);
launcher = (JNLPLauncher) agent.getLauncher();
assertThat(launcher.isWebSocket(), is(true));
assertThat(launcher.getWorkDirSettings().getInternalDir(), is("remoting2"));
assertThat(launcher.getTunnel(), is("someproxy"));
launcher = new JNLPLauncher();
launcher.setWebSocket(true);
agent.setLauncher(launcher);
agent = j.configRoundtrip(agent);
launcher = (JNLPLauncher) agent.getLauncher();
assertThat(launcher.isWebSocket(), is(true));
assertThat(launcher.getWorkDirSettings().getInternalDir(), is("remoting"));
assertThat(launcher.getTunnel(), nullValue());
}

@Test
public void testDefaults() {
assertFalse("Work directory enabled by default", new JNLPLauncher().getWorkDirSettings().isDisabled());
Expand Down
Loading