Bug #81791 NPE when closing a result set
Submitted: 9 Jun 2016 21:40 Modified: 15 Aug 2016 11:08
Reporter: John Krieger Email Updates:
Status: No Feedback Impact on me:
None 
Category:Connector / J Severity:S3 (Non-critical)
Version:5.1.39 OS:Linux (RHEL 6.5)
Assigned to: CPU Architecture:Any

[9 Jun 2016 21:40] John Krieger
Description:
See the stack trace below.

java.lang.NullPointerException
at com.mysql.jdbc.MysqlIO.clearInputStream(MysqlIO.java:903)
at com.mysql.jdbc.RowDataDynamic.close(RowDataDynamic.java:172)
at com.mysql.jdbc.ResultSetImpl.realClose(ResultSetImpl.java:6704)
at com.mysql.jdbc.ResultSetImpl.close(ResultSetImpl.java:851)
at sun.reflect.GeneratedMethodAccessor7.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at com.mysql.jdbc.MultiHostConnectionProxy$JdbcInterfaceProxy.invoke(MultiHostConnectionProxy.java:103)
at com.sun.proxy.$Proxy17.close(Unknown Source)
at sun.reflect.GeneratedMethodAccessor7.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at com.mysql.jdbc.MultiHostConnectionProxy$JdbcInterfaceProxy.invoke(MultiHostConnectionProxy.java:103)
at com.sun.proxy.$Proxy18.close(Unknown Source)
at org.apache.commons.dbcp.DelegatingResultSet.close(DelegatingResultSet.java:152)
at org.apache.commons.dbcp.DelegatingStatement.close(DelegatingStatement.java:163)
[...]

How to repeat:
Do not have a repeatable test case at this time. Will provide more detail as it becomes available.

Suggested fix:
line 103 shows

while ((len = this.mysqlInput.available()) > 0 && this.mysqlInput.skip(len) > 0) {

since both methods return an integer, the possibility exists that mySqlInput is null
[10 Jun 2016 10:02] Chiranjeevi Battula
Hello  John Krieger,

Thank you for the bug report.
I could not repeat this issue at my end with the provided information. 
If you can provide more information, feel free to add it to this bug and change the status back to 'Open'.

Thank you for your interest in MySQL.

Thanks,
Chiranjeevi.
[20 Jun 2016 20:19] Mark Matthews
Verified by inspection. There appears to be a race between the entire connection being physically closed at some point, and this cleanup by clearing the input stream. Clearing the input stream is not needed if it's already gone (null), so this loop probably should (1) atomically create a reference to the input stream locally, (2) early-exit if that value is null, and (3) use a local reference in the loop (so that it is not null).
[12 Jul 2016 16:47] Filipe Silva
Hi John,

I would really like to reproduce this issue, so far with no success. If you don't have a reproducible test case can you at least describe the situation where it occurs? How is your environment set up, connection properties you're setting?

Thanks,
[16 Aug 2016 1:00] Bugs System
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".