Example usage for io.netty.util.concurrent FastThreadLocal destroy

List of usage examples for io.netty.util.concurrent FastThreadLocal destroy

Introduction

In this page you can find the example usage for io.netty.util.concurrent FastThreadLocal destroy.

Prototype

public static void destroy() 

Source Link

Document

Destroys the data structure that keeps all FastThreadLocal variables accessed from non- FastThreadLocalThread s.

Usage

From source file:org.superbiz.javaee.listeners.AppContextListener.java

License:Apache License

@Override
public void contextDestroyed(final ServletContextEvent servletContextEvent) {
    logger.info("Destroying application context: {}", servletContextEvent.getServletContext().getContextPath());
    try {/*ww w.j av  a  2  s.co  m*/
        logger.info("Shutting down AbandonedConnection");
        AbandonedConnectionCleanupThread.shutdown();
    } catch (Throwable t) {
        logger.error("Exception shutting down AbandonedConnection: {}", t);
    }

    // This manually deregisters JDBC driver, which prevents Tomcat 7 from
    // complaining about memory leaks
    Enumeration<Driver> drivers = java.sql.DriverManager.getDrivers();
    while (drivers.hasMoreElements()) {
        java.sql.Driver driver = drivers.nextElement();
        logger.info("Deregistering JDBC driver: {}", driver);
        try {
            java.sql.DriverManager.deregisterDriver(driver);
        } catch (Throwable t) {
            logger.error("Exception deregistering drivers: {}", t);
        }
    }

    try {
        logger.info("Shutting down Redisson: {}", redisson.getConfig());
        redisson.shutdown();
    } catch (Exception e) {
        logger.error("Error shutting down Redisson: {}", e);
    }

    try {
        FastThreadLocal.removeAll();
        FastThreadLocal.destroy();
    } catch (Exception e) {
        logger.error("Fatal error: {}", e);
    }
}