classloader-leak-prevention
classloader-leak-prevention copied to clipboard
DriverManagerCleanUp can't really work for many scenarios
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.
Could you please adhere to the coding standards of the project, such as indentation with 2 spaces, camel humping etc?
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)?
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.
DriverManager.deregisterDriver
needs to be done via reflection too as it also checks caller classloader
Good catch @OlegYch ! Add some more work, though.
@OlegYch thanks your advices. I'm already change the code.
I accept your suggestion,please review again. The check failure was not caused by my commit.