Permalink
Browse files

JAVA-657: ReadPreference ignored for some commands due to case-sensit…

…ive comparison
  • Loading branch information...
1 parent 1d2e6fa commit fb03f36c142e308c43ee34048de9115ee4960b8b @jyemin jyemin committed Mar 9, 2013
Showing with 9 additions and 6 deletions.
  1. +6 −6 src/main/com/mongodb/DB.java
  2. +3 −0 src/test/com/mongodb/DBTest.java
View
12 src/main/com/mongodb/DB.java
@@ -43,13 +43,13 @@
static {
_obedientCommands.add("group");
_obedientCommands.add("aggregate");
- _obedientCommands.add("collStats");
- _obedientCommands.add("dbStats");
+ _obedientCommands.add("collstats");
+ _obedientCommands.add("dbstats");
_obedientCommands.add("count");
_obedientCommands.add("distinct");
- _obedientCommands.add("geoNear");
- _obedientCommands.add("geoSearch");
- _obedientCommands.add("geoWalk");
+ _obedientCommands.add("geonear");
+ _obedientCommands.add("geosearch");
+ _obedientCommands.add("geowalk");
}
/**
@@ -88,7 +88,7 @@ ReadPreference getCommandReadPreference(DBObject command, ReadPreference request
else
primaryRequired = true;
} else {
- primaryRequired = !_obedientCommands.contains(comString);
+ primaryRequired = !_obedientCommands.contains(comString.toLowerCase());
}
if (primaryRequired) {
View
3 src/test/com/mongodb/DBTest.java
@@ -119,6 +119,9 @@ public void testReadPreferenceObedience() {
obj = new BasicDBObject("count", 1);
assertEquals(ReadPreference.primary(), _db.getCommandReadPreference(obj, null));
+
+ obj = new BasicDBObject("collStats", 1);
+ assertEquals(ReadPreference.secondaryPreferred(), _db.getCommandReadPreference(obj, ReadPreference.secondaryPreferred()));
}
@Test(groups = {"basic"})

0 comments on commit fb03f36

Please sign in to comment.