Bug #108415 NullPointerException in AbstractQuery::stopQueryTimer

Submitted: 7 Sep 2022 13:47 Modified: 7 Oct 2024 20:00
Reporter: Markus Stoy Email Updates:
Status: Closed 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 2023 21:10] Anthony Milbourne
I have created a PR to fix this: https://github.com/mysql/mysql-connector-j/pull/92
[10 Jan 2023 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.

[12 Sep 2024 10:09] Filipe Silva
Duplicated by Bug#112211.
[7 Oct 2024 20:00] Daniel So
Posted by developer:
 
Added the following entry to the Connector/J 9.1.0 changelog: 

"When a QueryTimer was set, if a session failed, Connector/J returned a NullPointerException. With this fix, a SQL Exception is returned instead. Thanks to Ashwini Patil for contributing to the patch."
[12 Oct 2024 0:37] Daniel So
Posted by developer:
 
Updated the changelog entry to the following: 

"When a QueryTimer was set, if a session failed, Connector/J returned a NullPointerException. With this fix, a SQL Exception is returned instead. Thanks to Ashwini Patil for contributing to the patch. Thanks to Anthony Milbourne for contributing to the patch."
[15 Oct 2024 15:11] Daniel So
Posted by developer:
 
Updated the changelog entry to the following: 

"When a QueryTimer was set, if a session failed, Connector/J returned a NullPointerException. With this fix, a SQL Exception is returned instead. Thanks to Anthony Milbourne for contributing to this patch."

Portions of this website are copyright © 2001, 2002 The PHP Group

Page generated in 0.059 sec. using MySQL 8.4.7-u6-cloud

Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.