Uploaded image for project: 'MariaDB Connector/J'
  1. MariaDB Connector/J
  2. CONJ-88

org.mariadb.jdbc.MySQLResultSet.getTimestamp(int, Calendar) throws NullPointerException if column is NULL

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 1.1.6, 1.1.7
    • Fix Version/s: 1.1.8
    • Component/s: None
    • Labels:
      None

      Description

      Since getValueObject(columnIndex).getTimestamp(cal) may return null, the method can throw NullPointerException

      public Timestamp getTimestamp(int columnIndex, Calendar cal) throws SQLException {
          try {
              return new Timestamp(getValueObject(columnIndex).getTimestamp(cal).getTime());
          } catch (ParseException e) {
              throw SQLExceptionMapper.getSQLException("Could not parse timestamp",e);
          }
      }

      Easy fix is to check for null before attempting to call getTime()

      public Timestamp getTimestamp(int columnIndex, Calendar cal) throws SQLException {
          try {
          	Timestamp timestamp = getValueObject(columnIndex).getTimestamp(cal);
          	
              return timestamp == null ? null : new Timestamp(timestamp.getTime());
          } catch (ParseException e) {
              throw SQLExceptionMapper.getSQLException("Could not parse timestamp",e);
          }
      }

        Attachments

          Activity

            People

            Assignee:
            massimo.siani Massimo Siani (Inactive)
            Reporter:
            emattheis Erik Mattheis
            Votes:
            1 Vote for this issue
            Watchers:
            5 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:

                Git Integration

                Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.