move Resteasy cleanup into the ResteasyAllInOneServletDispatcher

This commit is contained in:
Sebastian Sdorra
2019-06-25 08:31:49 +02:00
parent 9662b8a00b
commit 56c7fcc114
2 changed files with 7 additions and 3 deletions

View File

@@ -15,6 +15,7 @@ import javax.inject.Singleton;
import javax.servlet.ServletConfig;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.ws.rs.ext.RuntimeDelegate;
/**
* Resteasy initialization and dispatching. This servlet combines the initialization of
@@ -66,5 +67,10 @@ public class ResteasyAllInOneServletDispatcher extends HttpServletDispatcher {
LOG.info("destroy resteasy");
super.destroy();
deployment.stop();
// ensure everything gets cleared, to avoid classloader leaks
ResteasyProviderFactory.clearInstanceIfEqual(ResteasyProviderFactory.getInstance());
ResteasyProviderFactory.clearContextData();
RuntimeDelegate.setInstance(null);
}
}

View File

@@ -49,9 +49,7 @@ final class ServletContextCleaner {
}
}
ResteasyProviderFactory.clearInstanceIfEqual(ResteasyProviderFactory.getInstance());
ResteasyProviderFactory.clearContextData();
RuntimeDelegate.setInstance(null);
}
private static boolean shouldRemove(String name) {