Uploaded image for project: 'Java Driver'
  1. Java Driver
  2. JAVA-3916

Driver decodes BsonInt64 as Integer

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

       

      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@mongodb.com Ross Lawley
            Reporter:
            aabrasha@gmail.com Andrii Abramov
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: