[JAVA-658] DBTCPConnector ignores readprefs for combination of legacy settings Created: 01/Oct/12  Updated: 08/Jan/13  Resolved: 20/Oct/12

Status: Closed
Project: Java Driver
Component/s: API
Affects Version/s: 2.9.0
Fix Version/s: 2.9.2, 2.10.0

Type: Bug Priority: Minor - P4
Reporter: Matt Schemmel Assignee: Jeffrey Yemin
Resolution: Done Votes: 1
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Backwards Compatibility: Minor Change

 Description   

The method DBTCPConnector#call incorrectly deals with read preferences when:

  • The read-preference on the DB or Mongo has been set to (the deprecated) ReadPreference.PRIMARY
  • The options on the collection or query have been set to include Bytes#QUERYOPTION_SLAVEOK

The beginning of the method tests the passed readPref against ReadPreference.primary() using object equality, so the inferred use of ReadPreference.secondaryPreferred() for slaveOk queries is not triggered.

The default read preference on the mongo is ReadPreference.primary() in the v2.9.0 dist, so this bug only affects code written against older releases that explicitly set ReadPreference.PRIMARY at some point.



 Comments   
Comment by auto [ 08/Jan/13 ]

Author:

{u'date': u'2012-10-01T21:39:10Z', u'email': u'jeff.yemin@10gen.com', u'name': u'Jeff Yemin'}

Message: JAVA-658: Making ReadPreference.primary == ReadPreference.primary() so that it's safe to do equality comparision
Branch: master
https://github.com/mongodb/mongo-java-driver/commit/f4f0b840b4ce38913f4089b4e0e4a1c29a18dd4a

Comment by auto [ 08/Jan/13 ]

Author:

{u'date': u'2012-10-01T21:39:10Z', u'email': u'jeff.yemin@10gen.com', u'name': u'Jeff Yemin'}

Message: JAVA-658: Making ReadPreference.primary == ReadPreference.primary() so that it's safe to do equality comparision
Branch: 2.10.x
https://github.com/mongodb/mongo-java-driver/commit/f4f0b840b4ce38913f4089b4e0e4a1c29a18dd4a

Comment by auto [ 10/Oct/12 ]

Author:

{u'date': u'2012-10-01T14:39:10-07:00', u'email': u'jeff.yemin@10gen.com', u'name': u'Jeff Yemin'}

Message: JAVA-658: Making ReadPreference.primary == ReadPreference.primary() so that it's safe to do equality comparision
Branch: master
https://github.com/mongodb/mongo-java-driver/commit/7c3f31f354710479ac6f3f099a3c9caa90208e80

Comment by auto [ 09/Oct/12 ]

Author:

{u'date': u'2012-10-01T14:39:10-07:00', u'email': u'jeff.yemin@10gen.com', u'name': u'Jeff Yemin'}

Message: JAVA-658: Making ReadPreference.primary == ReadPreference.primary() so that it's safe to do equality comparision
Branch: release-2.9.x
https://github.com/mongodb/mongo-java-driver/commit/f4f0b840b4ce38913f4089b4e0e4a1c29a18dd4a

Comment by Jeffrey Yemin [ 01/Oct/12 ]

Good find Matt. Thanks for the report.

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