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

ClassCastException in FindAndUpdateOperation

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Fixed
    • Affects Version/s: 3.11.0
    • Fix Version/s: 3.11.1
    • Component/s: Write Operations
    • Labels:
      None

      Description

      toBsonValueList casts Bson objects to BsonValue which errors when the actual value is eg. a Document.

      MongoCollection<Document> collection = // ...
       
      Document existing = collection.findOneAndUpdate(
          new Document("_id", 1), 
          Collections.singletonList(
              new Document("$set", new Document("title", "The Burning White"))
          ),
          new FindOneAndUpdateOptions().upsert(true));
      

        Attachments

          Activity

            People

            Assignee:
            jeff.yemin Jeffrey Yemin
            Reporter:
            cstrobl Christoph Strobl
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: