Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-14623

ObjectId.fromDate is not correct for all dates

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor - P4
    • Resolution: Fixed
    • Affects Version/s: 2.7.2
    • Fix Version/s: 2.7.5
    • Component/s: JavaScript
    • Labels:
    • Backwards Compatibility:
      Fully Compatible
    • Operating System:
      ALL
    • Steps To Reproduce:
      Hide

      Run the following code in a v2.7.2/v2.7.3 shell :

      > ok = Math.pow(2, 28)
      268435456
      > notok = ok -1 
      268435455
      > ObjectId.fromDate(new Date(ok  * 1000))
      ObjectId("100000000000000000000000")
      > ObjectId.fromDate(new Date(notok  * 1000))
      Error: invalid object id: length

      Show
      Run the following code in a v2.7.2/v2.7.3 shell : > ok = Math.pow(2, 28) 268435456 > notok = ok -1 268435455 > ObjectId.fromDate( new Date(ok * 1000)) ObjectId( "100000000000000000000000" ) > ObjectId.fromDate( new Date(notok * 1000)) Error: invalid object id: length
    • Sprint:
      Server 2.7.4, Server 2.7.5

      Description

      The ObjectId.fromDate fails for dates less than (Math.pow(2,28) - 1).

      The code on line 379 should look something like :

          var pad = "00000000";
          var hexSeconds = seconds.toString(16);
          hexSeconds = pad.substring(0, pad.length - hexSeconds.length) + hexSeconds;
      
      

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              jim.oleary James O'Leary
              Reporter:
              jim.oleary James O'Leary
              Participants:
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: