Skip to content

Commit fb03f36

Browse files
committed
JAVA-657: ReadPreference ignored for some commands due to case-sensitive comparison
1 parent 1d2e6fa commit fb03f36

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

src/main/com/mongodb/DB.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,13 @@ public abstract class DB {
4343
static {
4444
_obedientCommands.add("group");
4545
_obedientCommands.add("aggregate");
46-
_obedientCommands.add("collStats");
47-
_obedientCommands.add("dbStats");
46+
_obedientCommands.add("collstats");
47+
_obedientCommands.add("dbstats");
4848
_obedientCommands.add("count");
4949
_obedientCommands.add("distinct");
50-
_obedientCommands.add("geoNear");
51-
_obedientCommands.add("geoSearch");
52-
_obedientCommands.add("geoWalk");
50+
_obedientCommands.add("geonear");
51+
_obedientCommands.add("geosearch");
52+
_obedientCommands.add("geowalk");
5353
}
5454

5555
/**
@@ -88,7 +88,7 @@ ReadPreference getCommandReadPreference(DBObject command, ReadPreference request
8888
else
8989
primaryRequired = true;
9090
} else {
91-
primaryRequired = !_obedientCommands.contains(comString);
91+
primaryRequired = !_obedientCommands.contains(comString.toLowerCase());
9292
}
9393

9494
if (primaryRequired) {

src/test/com/mongodb/DBTest.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,9 @@ public void testReadPreferenceObedience() {
119119

120120
obj = new BasicDBObject("count", 1);
121121
assertEquals(ReadPreference.primary(), _db.getCommandReadPreference(obj, null));
122+
123+
obj = new BasicDBObject("collStats", 1);
124+
assertEquals(ReadPreference.secondaryPreferred(), _db.getCommandReadPreference(obj, ReadPreference.secondaryPreferred()));
122125
}
123126

124127
@Test(groups = {"basic"})

0 commit comments

Comments
 (0)