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

Calendar instance not cleared before being used in ResultSet.getTimestamp

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 1.4.6, 1.5.6
    • Fix Version/s: 1.5.7
    • Component/s: Other
    • Labels:
      None
    • Environment:
      Ubuntu 16.04, MariaDB server 10.0.28

      Description

      I do understand that the reason behind problem I'm describing is an edge case and actually not even officially supported according to https://mariadb.com/kb/en/mariadb/date/ and https://mariadb.com/kb/en/mariadb/datetime/. However, I think it's possible that it could cause issues in other cases as well.

      The Calendar instance used in MariaSelectResultSet.getTimestamp(byte[], ColumnInformation, Calendar) is not cleared before values are set in the synchronized block on lines 1656 to 1665.

      This doesn't normally cause any problems, but if the year part of the datetime value is 0000 and useLegacyDatetimeCode=false is used the Calendar instance is corrupted and won't produce correct timestamps afterwards.

      As can be seen below, the first number 3 in the CalendarNotWorking output is clearly incorrect.

      Output from the two attached samples:

      CalendarWorking:

      With useLegacyDatetimeCode=true:
      1, 2015-05-13 08:15:14: 1431494114000
      2, 0000-11-15 10:15:22: -62139800678000
      3, 2015-05-13 08:15:14: 1431494114000
      

      CalendarNotWorking:

      With useLegacyDatetimeCode=false:
      1, 2015-05-13 08:15:14: 1431504914000
      2, 0000-11-15 10:15:22: -62139793478000
      3, 2015-05-13 08:15:14: -125712920686000
      Clearing calendar..
      3, 2015-05-13 08:15:14: 1431504914000
      

        Attachments

          Activity

            People

            • Assignee:
              diego dupin Diego Dupin
              Reporter:
              slovdahl Sebastian Lövdahl
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: