[CONJ-312] NPE while loading a null from TIMESTAMP field using Resultset.getDate() Created: 2016-06-10  Updated: 2016-06-13  Resolved: 2016-06-13

Status: Closed
Project: MariaDB Connector/J
Component/s: Other
Affects Version/s: None
Fix Version/s: 1.4.6

Type: Bug Priority: Critical
Reporter: Roman Kliewer Assignee: Diego Dupin
Resolution: Fixed Votes: 0
Labels: None


 Description   

Trying to read from a nullable TIMESTAMP field with null value:

{{java.lang.NullPointerException: null
at org.mariadb.jdbc.internal.queryresults.resultset.MariaSelectResultSet.binaryDate(MariaSelectResultSet.java:3259)
at org.mariadb.jdbc.internal.queryresults.resultset.MariaSelectResultSet.getDate(MariaSelectResultSet.java:1440)
at org.mariadb.jdbc.internal.queryresults.resultset.MariaSelectResultSet.getDate(MariaSelectResultSet.java:1351)
at org.mariadb.jdbc.internal.queryresults.resultset.MariaSelectResultSet.getDate(MariaSelectResultSet.java:1363)}}

The NPE is thrown here while trying to create new Date from null because rawBytes.length==0

if you look at binaryTimestamp(...), there is already the following:

{{if (rawBytes.length == 0)

{ return null; }

}}

So i guess it is just missing in this method

Edit: oh god, jira formatting is a mess.



 Comments   
Comment by Diego Dupin [ 2016-06-13 ]

You're right, thanks for reporting !

This can occur with resultset.getDate() or resulset.getTime() (not resultset.getTimestamp() ) from a null timestamp field.

correction in commit : https://github.com/MariaDB/mariadb-connector-j/commit/b12536f0c301fb72070982f883957f2e21e4c327

a new correction version 1.4.6 will be released quickly.

Generated at Thu Feb 08 03:14:44 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.