[JAVA-2043] Initializing driver with a URI and slaveOk=false defaults reads to secondary Created: 19/Nov/15  Updated: 01/Apr/16  Resolved: 20/Nov/15

Status: Closed
Project: Java Driver
Component/s: Configuration
Affects Version/s: 3.1.1
Fix Version/s: 3.2.0

Type: Bug Priority: Major - P3
Reporter: Michael Everett Assignee: Jeffrey Yemin
Resolution: Done Votes: 0
Labels: cs, regression
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

There's a bug in com.mongodb.ConnectionString.java in the Java Driver.

        // handle legacy slaveok settings
        if (optionsMap.containsKey("slaveok") && !optionsMap.containsKey("readpreference")) {
            optionsMap.put("readpreference", asList("secondaryPreferred"));
        }

This check is assuming that if slaveok is set that it was set to slaveOk=true.

Here's the commit that introduced this bug: https://github.com/mongodb/mongo-java-driver/commit/edb6952fd76ca9eba72b5f018717cb58c0745c0f



 Comments   
Comment by Jeffrey Yemin [ 07/Dec/15 ]

The 3.2.0 driver, which contains a fix for this issue, has been released today.

Comment by Githook User [ 20/Nov/15 ]

Author:

{u'username': u'jyemin', u'name': u'Jeff Yemin', u'email': u'jeff.yemin@10gen.com'}

Message: JAVA-2043: In ConnectionString, set read preference based on value of slaveok option rather than assume the value is true.
Branch: master
https://github.com/mongodb/mongo-java-driver/commit/5b2eb874d0214b6f6656fdc40cf969bbe587095d

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