Skip to content

Commit fb6fd25

Browse files
authored
Merge branch 'master' into improve-assertion-failure-output
2 parents c6c8cb0 + 49b01a4 commit fb6fd25

File tree

4 files changed

+13
-4
lines changed

4 files changed

+13
-4
lines changed

pom.xml

+2
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@
7070
<!-- https://www.jenkins.io/doc/developer/plugin-development/choosing-jenkins-baseline/ -->
7171
<jenkins.baseline>2.479</jenkins.baseline>
7272
<jenkins.version>${jenkins.baseline}.1</jenkins.version>
73+
<!-- TODO until in parent -->
74+
<jenkins-test-harness.version>2403.v256947ecb_c8a_</jenkins-test-harness.version>
7375
<gitHubRepo>jenkinsci/${project.artifactId}-plugin</gitHubRepo>
7476
<spotless.check.skip>false</spotless.check.skip>
7577
</properties>

src/main/java/com/cloudbees/jenkins/support/SupportLogHandler.java

+1
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,7 @@ private void setFile(File file) throws FileNotFoundException {
234234
parentFile.mkdirs();
235235
}
236236

237+
StreamUtils.closeQuietly(null); // ensure class is loaded so close() can succeed
237238
boolean success = false;
238239
FileOutputStream fos = null;
239240
BufferedOutputStream bos = null;

src/main/java/com/cloudbees/jenkins/support/SupportPlugin.java

+9-4
Original file line numberDiff line numberDiff line change
@@ -862,6 +862,15 @@ public Void call() {
862862
// avoid double installation of the handler. JNLP agents can reconnect to the controller multiple times
863863
// and each connection gets a different RemoteClassLoader, so we need to evict them by class name,
864864
// not by their identity.
865+
closeAll();
866+
Runtime.getRuntime().addShutdownHook(new Thread(LogInitializer::closeAll, "close log handlers"));
867+
LogHolder.AGENT_LOG_HANDLER.setLevel(level);
868+
LogHolder.AGENT_LOG_HANDLER.setDirectory(new File(rootPath.getRemote(), SUPPORT_DIRECTORY_NAME), "all");
869+
ROOT_LOGGER.addHandler(LogHolder.AGENT_LOG_HANDLER);
870+
return null;
871+
}
872+
873+
private static void closeAll() {
865874
for (Handler h : ROOT_LOGGER.getHandlers()) {
866875
if (h.getClass()
867876
.getName()
@@ -874,10 +883,6 @@ public Void call() {
874883
}
875884
}
876885
}
877-
LogHolder.AGENT_LOG_HANDLER.setLevel(level);
878-
LogHolder.AGENT_LOG_HANDLER.setDirectory(new File(rootPath.getRemote(), SUPPORT_DIRECTORY_NAME), "all");
879-
ROOT_LOGGER.addHandler(LogHolder.AGENT_LOG_HANDLER);
880-
return null;
881886
}
882887
}
883888

src/test/java/com/cloudbees/jenkins/support/impl/SmartLogCleanerTest.java

+1
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ public void cleanUp() throws Exception {
4949
}
5050

5151
assertEquals(cacheDir.list().length, 2);
52+
agent2.toComputer().disconnect(null).get();
5253
j.getInstance().removeNode(agent2);
5354

5455
generateBundle();

0 commit comments

Comments
 (0)