https://issues.apache.org/bugzilla/show_bug.cgi?id=49667

           Summary: JdbcLeakPrevention class can register unregistered
                    JCBC Driver
           Product: Tomcat 7
           Version: 7.0.0
          Platform: PC
        OS/Version: Solaris
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Catalina
        AssignedTo: dev@tomcat.apache.org
        ReportedBy: arjencornelis.kni...@getronics.com


Overview
Suppose there is an web application A that uses a database and registers a
Driver with the java.sql.DriverManager, and a web application B that doesn't
use a database but has a jar file in its WEB-INF/lib directory that contains
the same Driver. Suppose you undeploy web application B.
Running the org.apache.catalina.loader.JdbcLeakPrevention class will actually
register the Driver and leave it loaded! The cause is the way the DriverManager
checks whether a ClassLoader has permission to load the Driver. It does that by
calling Class.forName with the ClassLoader, which will load the class if the
class has not been loaded by that ClassLoader. Loading a Driver class triggers
the Driver to register itself. 

Steps to reproduce
Create two web applications: one which registeres a Driver with the
java.sql.Drivermanager and one that uses no database. Put the jar containing
the Driver class in the WEB-INF/lib directory of both applications. Deploy both
in Tomcat. Then undeploy the latter one.
Inspect catalina.out, verify that there are no messages about a JDBC Driver
being forcibly unregistered.
Create a memory dump using jmap and inspect the dump using jhat.

Actual results
The WebappClassLoader for the latter application is still present. Its "rootset
references" page shows two reference chains from class java.sql.DriverManager:
Static reference from java.sql.DriverManager.readDrivers (from class
java.sql.DriverManager) :
--> java.util.vec...@0xeb6eb3f0 (24 bytes) (field elementData:)
--> [Ljava.lang.Object;@0xeb6eb408 (20 bytes) (Element 2 of
[Ljava.lang.Object;@0xeb6eb408:)
--> java.sql.driveri...@0xeb6eb420 (20 bytes) (field driverClass:)
--> class oracle.jdbc.driver.OracleDriver (84 bytes) (??:)
--> org.apache.catalina.loader.webappclassloa...@0xeb5a84a0 (157 bytes) 

and a similar one from java.sql.DriverManager.writeDrivers.

Expected results
The WebappClassLoader is not present in memory anymore.

Build date & platform
Downloaded Core tar.gz from http://tomcat.apache.org/download-70.cgi

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to