[JAVA-633] DBCollection.isCapped() method throws ClassCastException with mongodb-2.2.0 Created: 29/Aug/12  Updated: 10/Sep/12  Resolved: 07/Sep/12

Status: Closed
Project: Java Driver
Component/s: API
Affects Version/s: 2.7.3, 2.9.0
Fix Version/s: 2.9.1

Type: Bug Priority: Major - P3
Reporter: Alexei Krainiouk Assignee: Bryan Reinero
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Any.
(tested with 3.5.2-3.fc17.x86_64/jdk1.7.0_06(x64))


Attachments: Java Source File IsCappedTest.java    
Backwards Compatibility: Major Change

 Description   

Apparently mongodb 2.2.0 changed the type of "capped" property returned by getStats() method for collections from integer to boolean.
As a result an attempt to invoke DBCollection.isCapped() on capped collection when working with mongodb version 2.2.0 leads to ClassCastException.

I have attached the test that demonstrates the problem. The test will happily run with mongodb versions 2.0.x and below but fail with 2.2.0.
The source also provides an alternative implementation of isCapped() that fixes the problem.



 Comments   
Comment by Bryan Reinero [ 05/Sep/12 ]

Commited to master
https://github.com/mongodb/mongo-java-driver/commit/79637285d1f063d0076c9cac5c1b556b3efe54b6

Comment by Jeffrey Yemin [ 29/Aug/12 ]

Thanks for the report. We'll get this incorporated into the next release of the driver.

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