Bug #97241 Register JDBC Driver with DriverAction to cleanup resources
Submitted: 16 Oct 2019 3:13 Modified: 16 Jul 2020 11:13
Reporter: Yanming Zhou (OCA) Email Updates:
Status: Duplicate 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 2019 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 2019 6:17] Yanming Zhou
I have created https://github.com/mysql/mysql-connector-j/pull/44
[30 Oct 2019 6:03] MySQL Verification Team
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 2019 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 2019 4:15] MySQL Verification Team
Thank you for the contribution.

[16 Jul 2020 11:13] Filipe Silva
This is a duplicate of Bug#97435. Please check report updates there.