[JAVA-1555] BasicDBList not accepting double types anymore Created: 15/Nov/14  Updated: 11/Sep/19  Resolved: 06/Mar/15

Status: Closed
Project: Java Driver
Component/s: Codecs
Affects Version/s: 2.13.0
Fix Version/s: None

Type: Task Priority: Major - P3
Reporter: Krzys Assignee: Unassigned
Resolution: Cannot Reproduce Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Windows 7 64bit, IntelliJ Idea



 Description   

While moving through records with a cursor, when I retrieve a field that is an array e.g.
"tags":[4.0] and it only contains a single double while doing "BasicDBList l = (BasicDBList) o.get("Tags"); " I get
"Exception in thread "main" java.lang.ClassCastException: java.lang.Double cannot be cast to com.mongodb.BasicDBList"

There was no such a problem with previous stable version.



 Comments   
Comment by Jeffrey Yemin [ 06/Mar/15 ]

Closing since we have not heard back from you in quite some time. Please re-open if you have any updates to the last question posed.

Comment by Jeffrey Yemin [ 16/Nov/14 ]

I attempted to reproduce this report.

I first inserted a document using the shell:

> use java1555
switched to db java1555
> db.test.insert({tags : [4.2]})
WriteResult({ "nInserted" : 1 })
> db.test.findOne()
{ "_id" : ObjectId("5468c16bae2f5efbd4838832"), "tags" : [ 4.2 ] }

I then ran the following program with both 2.12.4 and 2.13.0-rc0:

        MongoClient mc = new MongoClient();
        System.out.println(mc.getVersion());
        DBObject doc = mc.getDB("java1555").getCollection("test").findOne();
        System.out.println(doc);
        List tags = (List) doc.get("tags");
        System.out.println(tags.getClass());
        System.out.println(tags);

Output using 2.12.4:

2.12.4
{ "_id" : { "$oid" : "5468c16bae2f5efbd4838832"} , "tags" : [ 4.2]}
class com.mongodb.BasicDBList
[ 4.2]

Output using 2.13.0-rc0:

2.13.0-rc0
{ "_id" : { "$oid" : "5468c16bae2f5efbd4838832"} , "tags" : [ 4.2]}
class com.mongodb.BasicDBList
[ 4.2]

Can you double-check that you are seeing this difference of behavior on the exact same document?

Generated at Thu Feb 08 08:54:54 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.