Bug #83662 NullPointerException while reading NULL boolean value from DB
Submitted: 3 Nov 2016 3:54 Modified: 11 May 2017 9:12
Reporter: Maxim Solodovnik Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / J Severity:S1 (Critical)
Version:5.1.40, 5.1.41 OS:Any
Assigned to: Filipe Silva CPU Architecture:Any

[3 Nov 2016 3:54] Maxim Solodovnik
Description:
NullPointerException is thrown when NULL Boolean value is being read from MySql DB.

Here is the stack trace:

java.lang.NullPointerException
     at com.mysql.jdbc.ResultSetImpl.getNumericRepresentationOfSQLBitType(ResultSetImpl.java:4936)
     at com.mysql.jdbc.ResultSetImpl.getInt(ResultSetImpl.java:2479)

The issue is not reproducible with 5.1.39 and earlier

How to repeat:
Create NULLABLE BIT(1) column in DB table
Set value to NULL

try to read it with Mysql Connector/J 5.1.40

Suggested fix:
Null check in com.mysql.jdbc.ResultSetImpl.getInt line 2472
Need to be placed BEFORE getNumericRepresentationOfSQLBitType call
[3 Nov 2016 6:12] Chiranjeevi Battula
Hello  Maxim Solodovnik,

Thank you for the bug report.
This is most likely duplicate of Bug #81202, please see Bug #81202.

Thanks,
Chiranjeevi.
[3 Nov 2016 6:15] Maxim Solodovnik
As I understand from bug descriptions for 81202 it was filed against version 6.0.x
What I have filed is clear regression comparing to version 5.1.39

I would appreciate if it can be fixed ASAP
The fix seems to be trivial ...
[3 Nov 2016 7:04] Maxim Solodovnik
Unlike #81202 it is regression to 5.1.39
[3 Nov 2016 7:38] Chiranjeevi Battula
Hello  Maxim Solodovnik,

Thank you for the bug feedback.
Even if you feel that your issue is somewhat different, the resolution is likely to be the same. Because of this, we hope you add your comments to the original bug instead.

Thanks,
Chiranjeevi.
[3 Nov 2016 9:28] Maxim Solodovnik
Maybe you can describe why this issue is marked as duplicate?

It affects different version
produces different stack trace
It doesn't connected with java.time .....
[4 Nov 2016 11:47] Chiranjeevi Battula
Hello  Maxim Solodovnik,

Thank you for the bug feedback.
Verified this behavior on MySQL Connector / J 5.1.40.

Thanks,
Chiranjeevi.
[4 Nov 2016 11:52] Chiranjeevi Battula
output:
Exception in thread "main" java.lang.NullPointerException
	at com.mysql.jdbc.ResultSetImpl.getNumericRepresentationOfSQLBitType(ResultSetImpl.java:4936)
	at com.mysql.jdbc.ResultSetImpl.getInt(ResultSetImpl.java:2479)
	at javaapplication3.bug_83662.main(bug_83662.java:29)
C:\Users\cbattula\AppData\Local\NetBeans\Cache\8.1\executor-snippets\run.xml:53: Java returned: 1
BUILD FAILED (total time: 1 second)
[23 Nov 2016 4:45] Maxim Solodovnik
Are there any estimates for this issue to be fixed?
[7 Dec 2016 3:05] Maxim Solodovnik
Can I help somehow to fix this?
Ant chance to speed up the fix? This issue is really critical for our project :(
[1 Mar 2017 6:43] Maxim Solodovnik
New version is out and this "Verified" NPE is not fixed
Is it that hard to fix?
[2 Mar 2017 10:21] Filipe Silva
Hi Maxim,

We weren't able to fix it in the just released Connector/J 5.1.41. We'll fix as soon as possible, but I can't just say if it will be in next version or not.

My apologies for the inconvenience.
[24 Mar 2017 17:44] Filipe Silva
Related to Bug#83368.
[20 Apr 2017 21:13] Daniel So
Posted by developer:
 
Added an entry to the Connector/J 5.1.42 changelog:

"A NullPointerException was thrown when a null boolean value was being read from the database."
[11 May 2017 9:12] Maxim Solodovnik
Thanks a lot!
Works as expected