提交 3bfa8af5 编写于 作者: K kohsuke

working around a memory leak in commons-logging. And they don't even...

working around a memory leak in commons-logging. And they don't even acknowledge that it's a bug. Sigh.


git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@2868 71c3de6d-444a-0410-be80-ed276b4c234a
上级 26ee3433
......@@ -18,6 +18,8 @@ import java.util.Set;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.apache.commons.logging.LogFactory;
/**
* Manages {@link PluginWrapper}s.
*
......@@ -129,6 +131,9 @@ public final class PluginManager {
for (PluginWrapper p : activePlugins) {
p.stop();
}
// Work around a bug in commons-logging.
// See http://www.szegedi.org/articles/memleak.html
LogFactory.release(uberClassLoader);
}
private final class UberClassLoader extends ClassLoader {
......
......@@ -5,6 +5,7 @@ import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.taskdefs.Expand;
import org.apache.tools.ant.types.FileSet;
import org.apache.commons.logging.LogFactory;
import org.kohsuke.stapler.StaplerRequest;
import org.kohsuke.stapler.StaplerResponse;
......@@ -356,6 +357,9 @@ public final class PluginWrapper {
System.err.println("Failed to shut down "+shortName);
System.err.println(t);
}
// Work around a bug in commons-logging.
// See http://www.szegedi.org/articles/memleak.html
LogFactory.release(classLoader);
}
/**
......
......@@ -32,6 +32,7 @@ import java.util.logging.Logger;
* @author Kohsuke Kawaguchi
*/
public class WebAppMain implements ServletContextListener {
private final RingBufferLogHandler handler = new RingBufferLogHandler();
/**
* Creates the sole instance of {@link Hudson} and register it to the {@link ServletContext}.
......@@ -116,7 +117,6 @@ public class WebAppMain implements ServletContextListener {
* Installs log handler to monitor all Hudson logs.
*/
private void installLogger() {
RingBufferLogHandler handler = new RingBufferLogHandler();
Hudson.logRecords = handler.getView();
Logger.getLogger("hudson").addHandler(handler);
}
......@@ -168,5 +168,9 @@ public class WebAppMain implements ServletContextListener {
Hudson instance = Hudson.getInstance();
if(instance!=null)
instance.cleanUp();
// Logger is in the system classloader, so if we don't do this
// the whole web app will never be undepoyed.
Logger.getLogger("hudson").removeHandler(handler);
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册