Skip to content

Commit 7e92923

Browse files
committed
Force garbage collection after stopping plugins
Java doesn't have any direct means to release unreferenced classloaders, so we force GC to do that so it becomes possible to delete plugin jar on Windows.
1 parent 5315b9d commit 7e92923

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

core/src/main/java/hudson/PluginManager.java

+4
Original file line numberDiff line numberDiff line change
@@ -1331,6 +1331,7 @@ public PluginWrapper whichPlugin(Class c) {
13311331
/**
13321332
* Orderly terminates all the plugins.
13331333
*/
1334+
@SuppressFBWarnings(value = "DM_GC", justification = "Garbage collection is required to release files held by plugin classloaders")
13341335
public void stop() {
13351336
for (PluginWrapper p : activePlugins) {
13361337
p.stop();
@@ -1340,6 +1341,9 @@ public void stop() {
13401341
// Work around a bug in commons-logging.
13411342
// See http://www.szegedi.org/articles/memleak.html
13421343
LogFactory.release(uberClassLoader);
1344+
// Java doesn't have any direct means to release unreferenced classloaders,
1345+
// so we force GC to do that so it becomes possible to delete plugin jar on Windows.
1346+
System.gc();
13431347
}
13441348

13451349
/**

0 commit comments

Comments
 (0)