From: markt Date: Mon, 21 Dec 2009 17:15:41 +0000 (+0000) Subject: Only unload JDBC drivers this web app loaded. X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=eddaf69fbfb22abc760c42ae07eafebd942d64b5;p=tomcat7.0 Only unload JDBC drivers this web app loaded. git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@892887 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/java/org/apache/catalina/loader/JdbcLeakPrevention.java b/java/org/apache/catalina/loader/JdbcLeakPrevention.java index 1aa103406..6f10dc8ca 100644 --- a/java/org/apache/catalina/loader/JdbcLeakPrevention.java +++ b/java/org/apache/catalina/loader/JdbcLeakPrevention.java @@ -38,23 +38,16 @@ import java.util.List; */ public class JdbcLeakPrevention { - /* - * This driver is visible to all classloaders but is loaded by the system - * class loader so there is no need to unload it. - */ - private static final String JDBC_ODBC_BRIDGE_DRIVER = - "sun.jdbc.odbc.JdbcOdbcDriver"; - public List clearJdbcDriverRegistrations() throws SQLException { List driverNames = new ArrayList(); - - // Unregister any JDBC drivers loaded by the class loader that loaded - // this class - ie the webapp class loader + + // This will list all drivers visible to this class loader Enumeration drivers = DriverManager.getDrivers(); while (drivers.hasMoreElements()) { Driver driver = drivers.nextElement(); - if (JDBC_ODBC_BRIDGE_DRIVER.equals( - driver.getClass().getCanonicalName())) { + // Only unload the drivers this web app loaded + if (driver.getClass().getClassLoader() != + this.getClass().getClassLoader()) { continue; } driverNames.add(driver.getClass().getCanonicalName());