Skip to content

Commit 6ee13e4

Browse files
committed
JAVA-406: Java driver does not accept empty keys
1 parent 5f23abf commit 6ee13e4

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/main/com/mongodb/DBApiLayer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ public WriteResult update( DBObject query , DBObject o , boolean upsert , boolea
315315
if (o != null && !o.keySet().isEmpty()) {
316316
// if 1st key doesn't start with $, then object will be inserted as is, need to check it
317317
String key = o.keySet().iterator().next();
318-
if (key.charAt(0) != '$')
318+
if (!key.startsWith("$"))
319319
_checkObject(o, false, false);
320320
}
321321

src/main/com/mongodb/DBCollection.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1078,7 +1078,7 @@ private void _checkKeys( DBObject o ) {
10781078
for ( String s : o.keySet() ){
10791079
if ( s.contains( "." ) )
10801080
throw new IllegalArgumentException( "fields stored in the db can't have . in them" );
1081-
if ( s.charAt( 0 ) == '$' )
1081+
if ( s.startsWith( "$" ) )
10821082
throw new IllegalArgumentException( "fields stored in the db can't start with '$'" );
10831083

10841084
Object inner;

0 commit comments

Comments
 (0)