dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #16848
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 6524: Unloading jdbc drivers at shutdown.
------------------------------------------------------------
revno: 6524
committer: Bob Jolliffe <bobjolliffe@xxxxxxxxx>
branch nick: dhis2
timestamp: Sun 2012-04-08 12:35:58 +0100
message:
Unloading jdbc drivers at shutdown.
Trying to catch memory leaks which prevent clean shutdown of tomcat. There are still more ...
modified:
dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/startup/StartupListener.java
--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk
Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/startup/StartupListener.java'
--- dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/startup/StartupListener.java 2011-12-26 10:07:59 +0000
+++ dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/startup/StartupListener.java 2012-04-08 11:35:58 +0000
@@ -27,9 +27,15 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+import java.sql.Driver;
+import java.sql.DriverManager;
+import java.sql.SQLException;
+import java.util.Enumeration;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;
@@ -40,6 +46,8 @@
public class StartupListener
implements ServletContextListener
{
+
+ private static final Log LOG = LogFactory.getLog( StartupListener.class );
// -------------------------------------------------------------------------
// ServletContextListener implementation
// -------------------------------------------------------------------------
@@ -64,5 +72,17 @@
public void contextDestroyed( ServletContextEvent event )
{
+ // cleanup jdbc drivers
+ Enumeration<Driver> drivers = DriverManager.getDrivers();
+ while (drivers.hasMoreElements()) {
+ Driver driver = drivers.nextElement();
+ try {
+ DriverManager.deregisterDriver(driver);
+ LOG.info("deregistering jdbc driver: " + driver);
+ } catch (SQLException e) {
+ LOG.info("Error deregistering driver " + driver + " :" + e.getMessage());
+ }
+ }
+
}
}