Skip to content

Deregister JDBC drivers during undeploy of a war deployment #21221

@BenICE

Description

@BenICE

Hi,

following up on the registration of JDBC drivers in Spring Boot (especially #2612).

As I can see it, no Spring Boot Application (e.g. 2.2.6) deregisters its JDBC driver.
Standard Spring Boot created with Spring boot initializr & In Memory H2 database, will leave its driver behind, which leads to a memory leak as the class loader cannot be GCed.

Why is there no huge outcry?

I guess these are the most standard cases, but if you run it in a JBoss environment you will not have much fun as the server will quickly rise an OOM after some deployments.

Workaround (which I deployed) is to deregister the driver in a context listener, when the context is destroyed (much like https://stackoverflow.com/questions/3320400/to-prevent-a-memory-leak-the-jdbc-driver-has-been-forcibly-unregistered/23912257#23912257).

Sure, we could relay on the Tomcat memory leak protection or deploy the database driver in the application server, but I would assume a War-file produced by Spring Boot should run everywhere.

What is your take on it?

Best

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions