Bug #34885 Unnecessary NullPointerException in ConnectionImpl
Submitted: 27 Feb 2008 11:50 Modified: 27 Feb 2008 14:08
Reporter: Nils Hammar Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / J Severity:S3 (Non-critical)
Version:5.1.5 OS:Any
Assigned to: CPU Architecture:Any

[27 Feb 2008 11:50] Nils Hammar
Description:
The method abortInternal() can throw a NullPointerException when it's called from the isValid() method where the isValid() method has a timeout value (E.g. isValid(1000) ).

This NPE seems to be harmless and is causing unnecessary logging.

How to repeat:
Check if a connection is valid through the isValid() call using a timeout value that is non-zero.

Suggested fix:
The following patch will resolve this:

---
Index: C:/Workspace/Telia2/connector-j-trunk/src/com/mysql/jdbc/ConnectionImpl.java
===================================================================
--- C:/Workspace/Telia2/connector-j-trunk/src/com/mysql/jdbc/ConnectionImpl.java	(revision 6740)
+++ C:/Workspace/Telia2/connector-j-trunk/src/com/mysql/jdbc/ConnectionImpl.java	(working copy)
@@ -1239,7 +1239,9 @@
 	 * @throws SQLException
 	 */
 	protected void abortInternal() throws SQLException {
-		io.forceClose();
+		if (io != null) {
+		    io.forceClose();
+		}
 		io = null;
 		isClosed = true;
 		cleanup(null);

---
[27 Feb 2008 14:08] Mark Matthews
This bug is already fixed in the source repository (in a slightly different way).
[27 Feb 2008 14:13] Tonci Grgin
Thank you for your bug report. This issue has been committed to our source repository of that product and will be incorporated into the next release.

If necessary, you can access the source repository and build the latest available version, including the bug fix. More information about accessing the source trees is available at

    http://dev.mysql.com/doc/en/installing-source.html

Explanation: Hi Nils and thanks for your report. As you can see, problem is already fixed.