Skip to content
Permalink
Browse files

[FIX JENKINS-4409] Release plugins and class loaders when JVM shuts d…

…own.

Originally-Committed-As: 2b9a083fbf2b9f4946ffa01e35dffea2b20a98d1
  • Loading branch information...
ikedam authored and kohsuke committed May 24, 2013
1 parent 5d3112c commit bfb70904a4c3cbeb90f1e55766ea2456695b73ea
Showing with 10 additions and 0 deletions.
  1. +10 −0 test/src/main/java/org/jvnet/hudson/test/TestPluginManager.java
@@ -113,6 +113,8 @@ private TestPluginManager() throws IOException {
return names;
}

// Overwrite PluginManager#stop, not to release plugins in each tests.
// Releasing plugins result fail to access files in webapp directory in following tests.
@Override
public void stop() {
for (PluginWrapper p : activePlugins)
@@ -126,6 +128,14 @@ public void stop() {
INSTANCE = new TestPluginManager();
Runtime.getRuntime().addShutdownHook(new Thread("delete " + INSTANCE.rootDir) {
@Override public void run() {
// Shutdown and release plugins as in PluginManager#stop
for(PluginWrapper p: INSTANCE.getPlugins()) {
p.stop();
p.releaseClassLoader();
}
INSTANCE.getPlugins().clear();
// allow JVM cleanup handles of jar files...
System.gc();
try {
Util.deleteRecursive(INSTANCE.rootDir);
} catch (IOException x) {

0 comments on commit bfb7090

Please sign in to comment.
You can’t perform that action at this time.