Bug #97241 Register JDBC Driver with DriverAction to cleanup resources
Submitted: 16 Oct 3:13 Modified: 30 Oct 6:03
Reporter: Yanming Zhou (OCA) Email Updates:
Status: Verified Impact on me:
Category:Connector / J Severity:S4 (Feature request)
Version:8.0.15 OS:Any
Assigned to: CPU Architecture:Any
Tags: Contribution

[16 Oct 3:13] Yanming Zhou
Currently application need call AbandonedConnectionCleanupThread.shutdown() to do graceful shutdown.
JDK introduce DriverAction since 1.8, Driver can switch registration from:
DriverManager.registerDriver(java.sql.Driver driver)
DriverManager.registerDriver(java.sql.Driver driver, DriverAction da)
Resources cleanup could be done in DriverAction callback, application should call DriverManager.deregisterDriver(Driver driver) instead of internal api.

How to repeat:
[16 Oct 6:17] Yanming Zhou
I have created https://github.com/mysql/mysql-connector-j/pull/44
[30 Oct 6:03] Umesh Shastry
Hello Yanming Zhou,

Thank you for the report and contribution.
I'll leave it for the Developers to take a call on which fix is better.
Please ensure to re-send the patch via "Contributions" tab. Otherwise we would not be able to accept it.

[31 Oct 0:10] Yanming Zhou
Patch download from github

(*) I confirm the code being submitted is offered under the terms of the OCA, and that I am authorized to contribute it.

Contribution: 97241.patch (application/octet-stream, text), 1001 bytes.

[31 Oct 4:15] Umesh Shastry
Thank you for the contribution.