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

ClassCastException in DocumentToDBRefTransformer during listCollections

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Gone away
    • Icon: Minor - P4 Minor - P4
    • None
    • None
    • None
    • None

    Description

      Summary

      When running MongoCollection#listCollections, the iterator fails with a ClassCastException in DocumentToDBRefTransformer.

      Please provide the version of the driver. If applicable, please provide the MongoDB server version and topology (standalone, replica set, or sharded cluster).

       

         Mongo Java Driver: 4.7.0

         MongoDB Atlas: 4.4.26

      How to Reproduce

      • Create a collection that uses DBRef
      • Run MongoClient#getDatabase#listCollections

      Additional Background

      This issue only occurs when DBRef is used in the database. It failed trying to transform a Document to a DBRef, expecting the fields $ref and $db to be Strings, but instead they were Documents. The Document that failed to transform is as follows:

       

      {

          $ref: {type: "string", description: "$ref must be a string and is required"},

          $id: {bsonType: "objectId", description: "$id must be an objectId and is required"},

          $db: {type: "string", description: "$db must be a string and is required"}

      }

      Attachments

        Activity

          People

            jeff.yemin@mongodb.com Jeffrey Yemin
            jonathan.savas@fivetran.com Jon Savas
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: