classloader-leak-prevention icon indicating copy to clipboard operation
classloader-leak-prevention copied to clipboard

DriverManagerCleanUp can't really work for many scenarios

Open Geker opened this issue 6 years ago • 7 comments

DriverManager.getDrivers() only return the drivers which be load by caller(DriverManagerCleanUp.class). For many scenarios the Caller is not the same classloader which load the jdbc Drivers. So ,DriverManager.getDrivers() will return empty driver list,and DriverManagerCleanUp do nothing. I think it need get registeredDrivers by reflection.

Geker avatar Apr 19 '18 03:04 Geker

Could you please adhere to the coding standards of the project, such as indentation with 2 spaces, camel humping etc?

mjiderhamn avatar Apr 19 '18 06:04 mjiderhamn

What is the scenario we're trying to solve here? The leak prevention library being part of a framework/application server, while the JDBC driver is dynamically loaded in an application instance (.war file)?

mjiderhamn avatar Apr 19 '18 06:04 mjiderhamn

Yes I have a app server. which have two level classloader. the server classloader load classloader-leak-prevention.jar .The server main-thread execute: runPreClassLoaderInitiators -> start war classloader (war-classloader load jdbc drivers / .war etc)->runCleanUps

I modify the code, please see the code again.

Geker avatar Apr 19 '18 07:04 Geker

DriverManager.deregisterDriver needs to be done via reflection too as it also checks caller classloader

OlegYch avatar Apr 24 '18 10:04 OlegYch

Good catch @OlegYch ! Add some more work, though.

mjiderhamn avatar Apr 24 '18 15:04 mjiderhamn

@OlegYch thanks your advices. I'm already change the code.

Geker avatar May 02 '18 08:05 Geker

I accept your suggestion,please review again. The check failure was not caused by my commit.

Geker avatar Jan 04 '19 09:01 Geker