Skip to content

Commit 81b915c

Browse files
authored
Merge branch 'master' into generate-support-bundle-async
2 parents 9b57a88 + 49b01a4 commit 81b915c

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
@@ -954,6 +954,15 @@ public Void call() {
954954
// avoid double installation of the handler. JNLP agents can reconnect to the controller multiple times
955955
// and each connection gets a different RemoteClassLoader, so we need to evict them by class name,
956956
// not by their identity.
957+
closeAll();
958+
Runtime.getRuntime().addShutdownHook(new Thread(LogInitializer::closeAll, "close log handlers"));
959+
LogHolder.AGENT_LOG_HANDLER.setLevel(level);
960+
LogHolder.AGENT_LOG_HANDLER.setDirectory(new File(rootPath.getRemote(), SUPPORT_DIRECTORY_NAME), "all");
961+
ROOT_LOGGER.addHandler(LogHolder.AGENT_LOG_HANDLER);
962+
return null;
963+
}
964+
965+
private static void closeAll() {
957966
for (Handler h : ROOT_LOGGER.getHandlers()) {
958967
if (h.getClass()
959968
.getName()
@@ -966,10 +975,6 @@ public Void call() {
966975
}
967976
}
968977
}
969-
LogHolder.AGENT_LOG_HANDLER.setLevel(level);
970-
LogHolder.AGENT_LOG_HANDLER.setDirectory(new File(rootPath.getRemote(), SUPPORT_DIRECTORY_NAME), "all");
971-
ROOT_LOGGER.addHandler(LogHolder.AGENT_LOG_HANDLER);
972-
return null;
973978
}
974979
}
975980

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)