Remove function creep

This commit is contained in:
René Pfeuffer
2019-06-06 11:15:51 +02:00
parent b26b702930
commit 1bcc150cb9
2 changed files with 15 additions and 17 deletions

View File

@@ -58,6 +58,8 @@ import sonia.scm.util.IOUtil;
import javax.inject.Inject;
import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
import java.io.Closeable;
import java.io.IOException;
import java.util.Collections;
import java.util.List;
import java.util.Set;
@@ -183,6 +185,18 @@ public class ScmContextListener extends GuiceResteasyBootstrapServletContextList
}
super.contextDestroyed(servletContextEvent);
for (PluginWrapper plugin : getPlugins()) {
ClassLoader pcl = plugin.getClassLoader();
if (pcl instanceof Closeable) {
try {
((Closeable) pcl).close();
} catch (IOException ex) {
LOG.warn("could not close plugin classloader", ex);
}
}
}
}
private void closeCloseables() {
@@ -205,6 +219,4 @@ public class ScmContextListener extends GuiceResteasyBootstrapServletContextList
private void destroyServletContextListeners(ServletContextEvent event) {
injector.getInstance(ServletContextListenerHolder.class).contextDestroyed(event);
}
}

View File

@@ -112,20 +112,6 @@ public class BootstrapContextListener implements ServletContextListener {
public void contextDestroyed(ServletContextEvent sce) {
contextListener.contextDestroyed(sce);
if (contextListener instanceof ScmContextListener) {
for (PluginWrapper plugin : ((ScmContextListener) contextListener).getPlugins()) {
ClassLoader pcl = plugin.getClassLoader();
if (pcl instanceof Closeable) {
try {
((Closeable) pcl).close();
} catch (IOException ex) {
logger.warn("could not close plugin classloader", ex);
}
}
}
}
context = null;
contextListener = null;
}