Skip to content

Commit

Permalink
Merge pull request #9113 from krisstern/feat/stable-2.440/backporting…
Browse files Browse the repository at this point in the history
…-2.440.3

chore: backporting 2.440.3
  • Loading branch information
basil committed Apr 4, 2024
2 parents 713e476 + 387f5a6 commit ef340a4
Show file tree
Hide file tree
Showing 6 changed files with 94 additions and 29 deletions.
4 changes: 2 additions & 2 deletions bom/pom.xml
Expand Up @@ -56,15 +56,15 @@ THE SOFTWARE.
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-framework-bom</artifactId>
<version>5.3.31</version>
<version>5.3.33</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<!-- https://docs.spring.io/spring-security/site/docs/5.5.4/reference/html5/#getting-maven-no-boot -->
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-bom</artifactId>
<version>5.8.9</version>
<version>5.8.11</version>
<type>pom</type>
<scope>import</scope>
</dependency>
Expand Down
2 changes: 1 addition & 1 deletion cli/pom.xml
Expand Up @@ -15,7 +15,7 @@
<url>https://github.com/jenkinsci/jenkins</url>

<properties>
<mina-sshd.version>2.11.0</mina-sshd.version>
<mina-sshd.version>2.12.1</mina-sshd.version>
<!-- Filled in by jacoco-maven-plugin -->
<jacocoSurefireArgs />
</properties>
Expand Down
5 changes: 4 additions & 1 deletion core/src/main/java/hudson/model/Computer.java
Expand Up @@ -63,6 +63,7 @@
import hudson.slaves.RetentionStrategy;
import hudson.slaves.WorkspaceList;
import hudson.triggers.SafeTimerTask;
import hudson.util.ClassLoaderSanityThreadFactory;
import hudson.util.DaemonThreadFactory;
import hudson.util.EditDistance;
import hudson.util.ExceptionCatchingThreadFactory;
Expand Down Expand Up @@ -1381,7 +1382,9 @@ public String call() throws IOException {
Executors.newCachedThreadPool(
new ExceptionCatchingThreadFactory(
new NamingThreadFactory(
new DaemonThreadFactory(), "Computer.threadPoolForRemoting")))), ACL.SYSTEM2));
new ClassLoaderSanityThreadFactory(new DaemonThreadFactory()),
"Computer.threadPoolForRemoting")))),
ACL.SYSTEM2));

//
//
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/java/hudson/slaves/SlaveComputer.java
Expand Up @@ -386,7 +386,7 @@ public boolean isConnecting() {
public OutputStream openLogFile() {
try {
log.rewind();
return log;
return decorate(log);
} catch (IOException e) {
logger.log(Level.SEVERE, "Failed to create log file " + getLogFile(), e);
return OutputStream.nullOutputStream();
Expand Down
40 changes: 40 additions & 0 deletions core/src/test/java/hudson/model/ComputerTest.java
Expand Up @@ -8,9 +8,11 @@
import hudson.FilePath;
import hudson.security.ACL;
import java.io.File;
import java.util.ArrayList;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import jenkins.model.Jenkins;
import jenkins.util.SetContextClassLoader;
import org.junit.Test;
import org.jvnet.hudson.test.Issue;
import org.springframework.security.core.Authentication;
Expand Down Expand Up @@ -45,4 +47,42 @@ public void testThreadPoolForRemotingActsAsSystemUser() throws InterruptedExcept
Future<Authentication> job = Computer.threadPoolForRemoting.submit(Jenkins::getAuthentication2);
assertThat(job.get(), is(ACL.SYSTEM2));
}

@Issue("JENKINS-72796")
@Test
public void testThreadPoolForRemotingContextClassLoaderIsSet() throws Exception {
// as the threadpool is cached, any other tests here pollute this test so we need enough threads to
// avoid any cached.
final int numThreads = 5;

// simulate the first call to Computer.threadPoolForRemoting with a non default classloader
try (var ignored = new SetContextClassLoader(new ClassLoader() {})) {
obtainAndCheckThreadsContextClassloaderAreCorrect(numThreads);
}
// now repeat this as the checking that the pollution of the context classloader is handled
obtainAndCheckThreadsContextClassloaderAreCorrect(numThreads);
}

private static void obtainAndCheckThreadsContextClassloaderAreCorrect(int numThreads) throws Exception {
ArrayList<Future<ClassLoader>> classloaderFuturesList = new ArrayList<>();
// block all calls to getContextClassloader() so we create more threads.
synchronized (WaitAndGetContextClassLoader.class) {
for (int i = 0; i < numThreads; i++) {
classloaderFuturesList.add(Computer.threadPoolForRemoting.submit(WaitAndGetContextClassLoader::getContextClassloader));
}
}
for (Future<ClassLoader> fc : classloaderFuturesList) {
assertThat(fc.get(), is(Jenkins.class.getClassLoader()));
}
}

private static class WaitAndGetContextClassLoader {

public static synchronized ClassLoader getContextClassloader() throws InterruptedException {
ClassLoader ccl = Thread.currentThread().getContextClassLoader();
// intentionally pollute the Threads context classloader
Thread.currentThread().setContextClassLoader(new ClassLoader() {});
return ccl;
}
}
}
70 changes: 46 additions & 24 deletions war/pom.xml
Expand Up @@ -46,6 +46,7 @@ THE SOFTWARE.
<host>localhost</host>
<!-- HTTP listener port -->
<port>8080</port>
<mina-sshd-api.version>2.12.1-101.v85b_e08b_780dd</mina-sshd-api.version>
<node.version>20.10.0</node.version>
<!-- frontend-maven-plugin will install this Yarn version as bootstrap, then hand over control to Yarn Berry. -->
<yarn.version>1.22.19</yarn.version>
Expand Down Expand Up @@ -289,14 +290,14 @@ THE SOFTWARE.
<!-- detached after 1.493 -->
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>mailer</artifactId>
<version>463.vedf8358e006b_</version>
<version>472.vf7c289a_4b_420</version>
<type>hpi</type>
</artifactItem>
<artifactItem>
<!-- detached after 1.535 -->
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>matrix-auth</artifactId>
<version>3.2.1</version>
<version>3.2.2</version>
<type>hpi</type>
</artifactItem>
<artifactItem>
Expand All @@ -317,35 +318,35 @@ THE SOFTWARE.
<!-- dependency of command-launcher, junit, matrix-project, and workflow-support -->
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>script-security</artifactId>
<version>1294.v99333c047434</version>
<version>1326.vdb_c154de8669</version>
<type>hpi</type>
</artifactItem>
<artifactItem>
<!-- detached after 1.577 -->
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>junit</artifactId>
<version>1240.vf9529b_881428</version>
<version>1265.v65b_14fa_f12f0</version>
<type>hpi</type>
</artifactItem>
<artifactItem>
<!-- dependency of junit, plugin-util-api, and workflow-support -->
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-api</artifactId>
<version>1283.v99c10937efcb_</version>
<version>1291.v51fd2a_625da_7</version>
<type>hpi</type>
</artifactItem>
<artifactItem>
<!-- dependency of checks-api, echarts-api, font-awesome-api, and junit -->
<groupId>io.jenkins.plugins</groupId>
<artifactId>plugin-util-api</artifactId>
<version>3.6.0</version>
<version>4.1.0</version>
<type>hpi</type>
</artifactItem>
<artifactItem>
<!-- dependency of echarts-api and junit -->
<groupId>io.jenkins.plugins</groupId>
<artifactId>bootstrap5-api</artifactId>
<version>5.3.2-2</version>
<version>5.3.3-1</version>
<type>hpi</type>
</artifactItem>
<artifactItem>
Expand All @@ -360,22 +361,22 @@ THE SOFTWARE.
<!-- dependency of checks-api and plugin-util-api -->
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-support</artifactId>
<version>865.v43e78cc44e0d</version>
<version>896.v175a_a_9c5b_78f</version>
<type>hpi</type>
</artifactItem>

<artifactItem>
<!-- dependency of junit and echarts-api -->
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>jackson2-api</artifactId>
<version>2.15.3-372.v309620682326</version>
<version>2.17.0-379.v02de8ec9f64c</version>
<type>hpi</type>
</artifactItem>
<artifactItem>
<!-- dependency of junit -->
<groupId>io.jenkins.plugins</groupId>
<artifactId>echarts-api</artifactId>
<version>5.4.3-1</version>
<version>5.5.0-1</version>
<type>hpi</type>
</artifactItem>

Expand All @@ -399,44 +400,44 @@ THE SOFTWARE.
<!-- dependency of echarts-api -->
<groupId>io.jenkins.plugins</groupId>
<artifactId>jquery3-api</artifactId>
<version>3.7.1-1</version>
<version>3.7.1-2</version>
<type>hpi</type>
</artifactItem>

<artifactItem>
<!-- dependency of bootstrap5-api and echarts-api -->
<groupId>io.jenkins.plugins</groupId>
<artifactId>font-awesome-api</artifactId>
<version>6.4.2-1</version>
<version>6.5.1-3</version>
<type>hpi</type>
</artifactItem>

<artifactItem>
<!-- dependency of checks-api, junit, plugin-util-api, workflow-api, and workflow-support -->
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-step-api</artifactId>
<version>639.v6eca_cd8c04a_a_</version>
<version>657.v03b_e8115821b_</version>
<type>hpi</type>
</artifactItem>
<artifactItem>
<!-- dependency of workflow-api and workflow-support -->
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>scm-api</artifactId>
<version>683.vb_16722fb_b_80b_</version>
<version>689.v237b_6d3a_ef7f</version>
<type>hpi</type>
</artifactItem>
<artifactItem>
<!-- dependency of scm-api and workflow-step-api -->
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>structs</artifactId>
<version>325.vcb_307d2a_2782</version>
<version>337.v1b_04ea_4df7c8</version>
<type>hpi</type>
</artifactItem>
<artifactItem>
<!-- detached after 2.16 -->
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>bouncycastle-api</artifactId>
<version>2.29</version>
<version>2.30.1.77-225.v26ea_c9455fd9</version>
<type>hpi</type>
</artifactItem>
<artifactItem>
Expand Down Expand Up @@ -464,14 +465,14 @@ THE SOFTWARE.
<!-- detached after 2.281 -->
<groupId>org.jenkins-ci.modules</groupId>
<artifactId>sshd</artifactId>
<version>3.312.v1c601b_c83b_0e</version>
<version>3.322.v159e91f6a_550</version>
<type>hpi</type>
</artifactItem>
<artifactItem>
<!-- detached after 2.184 -->
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>trilead-api</artifactId>
<version>2.84.v72119de229b_7</version>
<version>2.142.v748523a_76693</version>
<type>hpi</type>
</artifactItem>
<artifactItem>
Expand Down Expand Up @@ -502,6 +503,13 @@ THE SOFTWARE.
<version>4.5.14-208.v438351942757</version>
<type>hpi</type>
</artifactItem>
<artifactItem>
<!-- dependency of scm-api -->
<groupId>io.jenkins.plugins</groupId>
<artifactId>asm-api</artifactId>
<version>9.6-3.v2e1fa_b_338cd7</version>
<type>hpi</type>
</artifactItem>
<artifactItem>
<!-- dependency of bootstrap5-api, checks-api, commons-text-api, echarts-api, font-awesome-api, jquery3-api, and plugin-util-api -->
<groupId>io.jenkins.plugins</groupId>
Expand All @@ -513,42 +521,56 @@ THE SOFTWARE.
<!-- dependency of bootstrap5-api, checks-api, echarts-api, font-awesome-api, jquery3-api, and plugin-util-api -->
<groupId>io.jenkins.plugins</groupId>
<artifactId>commons-text-api</artifactId>
<version>1.11.0-94.v3e1f4a_926e49</version>
<version>1.11.0-95.v22a_d30ee5d36</version>
<type>hpi</type>
</artifactItem>
<artifactItem>
<!-- dependency of trilead-api -->
<groupId>io.jenkins.plugins</groupId>
<artifactId>gson-api</artifactId>
<version>2.10.1-15.v0d99f670e0a_7</version>
<type>hpi</type>
</artifactItem>
<artifactItem>
<!-- dependency of junit and matrix-auth -->
<groupId>io.jenkins.plugins</groupId>
<artifactId>ionicons-api</artifactId>
<version>56.v1b_1c8c49374e</version>
<version>70.v2959a_b_74e3cf</version>
<type>hpi</type>
</artifactItem>
<artifactItem>
<!-- dependency of jakarta-mail-api -->
<groupId>io.jenkins.plugins</groupId>
<artifactId>jakarta-activation-api</artifactId>
<version>2.0.1-3</version>
<version>2.1.3-1</version>
<type>hpi</type>
</artifactItem>
<artifactItem>
<!-- dependency of mailer -->
<groupId>io.jenkins.plugins</groupId>
<artifactId>jakarta-mail-api</artifactId>
<version>2.0.1-3</version>
<version>2.1.3-1</version>
<type>hpi</type>
</artifactItem>
<artifactItem>
<!-- dependency of jackson2-api -->
<groupId>io.jenkins.plugins</groupId>
<artifactId>json-api</artifactId>
<version>20240303-41.v94e11e6de726</version>
<type>hpi</type>
</artifactItem>
<artifactItem>
<!-- dependency of mina-sshd-api-core and sshd -->
<groupId>io.jenkins.plugins.mina-sshd-api</groupId>
<artifactId>mina-sshd-api-common</artifactId>
<version>2.11.0-86.v836f585d47fa_</version>
<version>${mina-sshd-api.version}</version>
<type>hpi</type>
</artifactItem>
<artifactItem>
<!-- dependency of sshd -->
<groupId>io.jenkins.plugins.mina-sshd-api</groupId>
<artifactId>mina-sshd-api-core</artifactId>
<version>2.11.0-86.v836f585d47fa_</version>
<version>${mina-sshd-api.version}</version>
<type>hpi</type>
</artifactItem>
</artifactItems>
Expand Down

0 comments on commit ef340a4

Please sign in to comment.