Driver decodes BsonInt64 as Integer

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Fixed
    • Priority: Major - P3
    • 4.2.0
    • Affects Version/s: 4.1.0
    • Component/s: Scala
    • None
    • Environment:
    • None
    • None
    • None
    • None
    • None
    • None
    • None

       

      Driver fails to read `BsonInt64` as Long and results in ClassCastException:

       

      Minimal reproducible example:

      https://gist.github.com/aaabramov/89625595893d0ff513d1512b43a21caa

       

      What happens here is that driver reads `field` as an `Integer` and puts it into `org.bson.Document#documentAsMap` then tries to class it as a `Long` in `org.bson.Document#getLong`.

       

      And the interesting thing is we'll try to persist `coll.insertOne(Document("field" -> BsonInt64(Long.MaxValue))).toFuture()` everything would work just fine. So seems that driver chooses resulting type based on its value?

       

      It was working fine with driver `"org.mongodb.scala" %% "mongo-scala-driver" % "2.7.0"`

       

              Assignee:
              Ross Lawley
              Reporter:
              Andrii Abramov
              None
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Created:
                Updated:
                Resolved: