Initializing driver with a URI and slaveOk=false defaults reads to secondary

XMLWordPrintableJSON

    • None
    • None
    • None
    • None
    • None
    • None
    • None

      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

            Assignee:
            Jeffrey Yemin
            Reporter:
            Michael Everett
            None
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: