Skip to content

Commit 893eb99

Browse files
committed
JAVA-2393: Enable max staleness validity checks when read preference mode is primary preferred and the primary is available
1 parent d5ec428 commit 893eb99

File tree

2 files changed

+2
-3
lines changed

2 files changed

+2
-3
lines changed

driver-core/src/main/com/mongodb/TaggableReadPreference.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ public String getName() {
379379
@Override
380380
@SuppressWarnings("deprecation")
381381
protected List<ServerDescription> chooseForReplicaSet(final ClusterDescription clusterDescription) {
382-
List<ServerDescription> selectedServers = clusterDescription.getPrimaries();
382+
List<ServerDescription> selectedServers = selectFreshServers(clusterDescription, clusterDescription.getPrimaries());
383383
if (selectedServers.isEmpty()) {
384384
selectedServers = super.chooseForReplicaSet(clusterDescription);
385385
}

driver-core/src/test/unit/com/mongodb/connection/ServerSelectionSelectionTest.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,8 @@ public ServerSelectionSelectionTest(final String description, final BsonDocument
7171

7272
@Test
7373
public void shouldPassAllOutcomes() {
74-
// skip these tests because the driver prohibits maxStaleness or tagSets with mode of primary at a much lower level
74+
// skip this test because the driver prohibits maxStaleness or tagSets with mode of primary at a much lower level
7575
assumeTrue(!description.equals("max-staleness/server_selection/ReplicaSetWithPrimary/MaxStalenessWithModePrimary.json"));
76-
assumeTrue(!description.equals("max-staleness/server_selection/ReplicaSetWithPrimary/PrimaryPreferred_incompatible.json"));
7776

7877
ServerSelector serverSelector = null;
7978
List<ServerDescription> suitableServers = buildServerDescriptions(definition.getArray("suitable_servers" , new BsonArray()));

0 commit comments

Comments
 (0)