[CSHARP-61] Error in MongoDB.Bson.BsonReader.ReadElementType(Int32 typeNumber) when reading type Timestamp Created: 03/Sep/10  Updated: 19/Oct/16  Resolved: 07/Sep/10

Status: Closed
Project: C# Driver
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Critical - P2
Reporter: Syed Saleem Javid Brahmanapalli Assignee: Steve Wagner
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

The method ReadElementType does not handle BsonType.Timestamp.

This issue shows ups when the mongodb server is running in replication mode and the driver queries the GetLastError from the DB after performing a save/update operation.
The server responds (with the result as per the spec for OP_REPLY http://www.mongodb.org/display/DOCS/Mongo+Wire+Protocol#MongoWireProtocol-OPREPLY) with 1 document

The hex dump for the BSON document is

3F-00-00-00-0A-65-72-72-00-08-75-70-64-61-74-65-64-45-78-69-73-74-69-6E-67-00-01-10-6E-00-01-00-00-00-11-6C-61-73-74-4F-70-00-01-00-00-00-84-2F-81-4C-01-6F-6B-00-00-00-00-00-00-00-F0-3F-00

which when translate to JSON should look like
{
"err" : null,
"updatedExisting" : true,
"n" : 1,
"lastOp" :

{ "t" : 1283534737000, "i" : 1 }

,
"ok" : 1
}

But the BsonReader throws an ArgumentOutOfRangeException exception.

Adding (case BsonType.Timestamp at line 143 in the file samus-mongodb-csharp-85d3524\source\MongoDB\Bson\BsonReader.cs would solve the issue.

Thanks,
Saleem



 Comments   
Comment by Steve Wagner [ 07/Sep/10 ]

Timestamps are now supported. To map a timestamp you need to set the property to type MongoTimestamp. The deserializer can also convert it back to long. But be aware that when you write such document, the values is written as long instead of timestamp.

You can find the change in my unstable branch.

http://github.com/lanwin/mongodb-csharp/tree/1.6_prep

Comment by Steve Wagner [ 05/Sep/10 ]

I hope to start with that tomorrow.

Generated at Wed Feb 07 21:35:42 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.