reset resteasy StatisticsController to avoid ClassLoader leaks

This commit is contained in:
Sebastian Sdorra
2019-11-21 16:22:39 +01:00
parent 571f5aa421
commit 2fde622560

View File

@@ -7,6 +7,7 @@ import org.jboss.resteasy.plugins.server.servlet.ListenerBootstrap;
import org.jboss.resteasy.spi.Registry;
import org.jboss.resteasy.spi.ResteasyDeployment;
import org.jboss.resteasy.spi.ResteasyProviderFactory;
import org.jboss.resteasy.spi.statistics.StatisticsController;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -70,6 +71,12 @@ public class ResteasyAllInOneServletDispatcher extends HttpServletDispatcher {
super.destroy();
deployment.stop();
// clear ResourceLocatorInvoker leaks
StatisticsController statisticsController = ResteasyProviderFactory.getInstance().getStatisticsController();
if (statisticsController != null) {
statisticsController.reset();
}
// ensure everything gets cleared, to avoid classloader leaks
ResteasyProviderFactory.clearInstanceIfEqual(ResteasyProviderFactory.getInstance());
RuntimeDelegate.setInstance(null);