Bug #108415 NullPointerException in AbstractQuery::stopQueryTimer
Submitted: 7 Sep 2022 13:47 Modified: 8 Sep 2022 12:48
Reporter: Markus Stoy Email Updates:
Status: Verified Impact on me:
None 
Category:Connector / J Severity:S3 (Non-critical)
Version:8.0.30 OS:Any
Assigned to: CPU Architecture:Any

[7 Sep 2022 13:47] Markus Stoy
Description:
When the MySQL server dies while queries are being run, the MySQL Connector/J 8.0.30 occasionally fails with a NullPointerException in AbstractQuery::stopQueryTimer, rather than a more useful CommunicationsException.

See https://github.com/mikevink/mysql_connector_j_8_npe/blob/github/readme.md for a more detailed description of the issue.

How to repeat:
See https://github.com/mikevink/mysql_connector_j_8_npe for a sample project that reproduces the issue.

Suggested fix:
The simplest solution would be to add a null-check to AbstractQuery::stopQueryTimer:

if (this.session != null) {
    this.session.getCancelTimer().purge();
}
[8 Sep 2022 12:48] MySQL Verification Team
Hello Markus,

Thank you for the bug report.
Verified as described.

Regards,
Ashwini Patil
[10 Jan 21:10] Anthony Milbourne
I have created a PR to fix this: https://github.com/mysql/mysql-connector-j/pull/92
[10 Jan 22:45] OCA Admin
Contribution submitted via Github - Fix for Bug #108415 - Occasional NPE when server dies 
(*) Contribution by Anthony Milbourne (Github amilbourne, mysql-connector-j/pull/92): This just adds a very simple null-check guard as suggested in the bug report here:
https://bugs.mysql.com/bug.php?id=108415

I have not added a test as this is a very small change and probably not worth the overhead of a test.  Also, this is my first contribution and I have no idea how to test this.

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

Contribution: git_patch_1176870298.txt (text/plain), 1.07 KiB.