[JAVA-1971] System-generated index names assume asc/desc is specified with an Int32 Created: 18/Sep/15  Updated: 07/Oct/15  Resolved: 25/Sep/15

Status: Closed
Project: Java Driver
Component/s: None
Affects Version/s: 3.0.4
Fix Version/s: 3.1.0

Type: Bug Priority: Minor - P4
Reporter: Gordon Syme Assignee: Ross Lawley
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: Text File generateIndexNames.patch    

 Description   

com.mongodb.operations.IndexHelper#generateIndexName assumes that the ascending/descending specifier for a key is either a BsonInt32 or a String.

In the case of Clojure (at least), integer literals default to Long rather than Integer. The translation from a DBObject to a BsonDocument converts these longs to BsonInt64 types.

This causes system generated index names to elide the ascending/descending information leading to index name collisions.

Not a blocker, the obvious workaround is to ensure ascending/descending specifiers are Integers.

I've attached a patch that uses BsonNumber to avoid this issue and confirmed it works when invoked from Clojure. Obviously I've got very limited context into the development of Mongo's Java driver so this probably isn't the right approach, but does illustrate the issue.



 Comments   
Comment by Jeffrey Yemin [ 07/Oct/15 ]

Released in 3.1.0

Comment by Githook User [ 25/Sep/15 ]

Author:

{u'username': u'rozza', u'name': u'Ross Lawley', u'email': u'ross.lawley@gmail.com'}

Message: Updated IndexHelper to take any BsonNumber

JAVA-1971
Branch: master
https://github.com/mongodb/mongo-java-driver/commit/169aa0c5db4387874b62005672ebdf529e9905c9

Comment by Jeffrey Yemin [ 18/Sep/15 ]

Hi Gordon,

I'll try to get this into the 3.1 release. Thanks for the report.

I think the fix looks good. Just need to add a test for it.

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