[JAVA-406] Java driver does not accept empty keys Created: 03/Aug/11  Updated: 10/Aug/11  Resolved: 05/Aug/11

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

Type: Bug Priority: Major - P3
Reporter: Ronald K. Muller Assignee: Antoine Girbal
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

linux / java 6



 Description   

which are perfect valid if using the shell:
> db.po.insert(

{"":1}

);
> db.po.insert(

{"":2}

);
> db.po.find(

{"":1}

);

{ "_id" : ObjectId("4e3940ff933089c859e4d4f9"), "" : 1 }

error source:
private void _checkKeys( DBObject o ) {
for ( String s : o.keySet() ){
if ( s.contains( "." ) )
throw new IllegalArgumentException( "fields stored in
the db can't have . in them" );
if ( s.charAt( 0 ) == '$' )
throw new IllegalArgumentException( "fields stored in
the db can't start with '$'" );
Object inner;
if ( (inner = o.get( s )) instanceof DBObject )

{ _checkKeys( (DBObject)inner ); }


}
}

if ( s.charAt( 0 ) == '$' )
should be:
if (s.startWith('$' ))



 Comments   
Comment by auto [ 05/Aug/11 ]

Author:

{u'login': u'agirbal', u'name': u'agirbal', u'email': u'antoine@10gen.com'}

Message: JAVA-406: Java driver does not accept empty keys
Branch: master
https://github.com/mongodb/mongo-java-driver/commit/6ee13e421d54ebb0324cd7569fa68038ff8b7be5

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