[JAVA-2323] Don't allow 0 maxStaleness in ReadPreference API Created: 26/Sep/16  Updated: 26/Dec/19  Resolved: 06/Oct/16

Status: Closed
Project: Java Driver
Component/s: Query Operations
Affects Version/s: None
Fix Version/s: 3.4.0-rc1, 3.4.0

Type: Improvement Priority: Major - P3
Reporter: Jeffrey Yemin Assignee: Jeffrey Yemin
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

The driver currently allows a value of 0 for maxStaleness, which it documents to mean "no maximum". This is unnecessarily confusing, as users might thing, despite the API docs, that maxStaleness of 0 means "totally fresh".

Consider changing the ReadPreference API to not treat 0 specially, and require either:

  • use of overloaded factory methods that don't take a maxStaleness parameter to indicate that there is no maximum
  • use boxed Long so that null can be passed as a value, and don't treat 0 specially.


 Comments   
Comment by Githook User [ 05/Oct/16 ]

Author:

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

Message: JAVA-2323: Use -1 to explicitly represent no max staleness in the connection string, and stop using 0 to represent it in the ReadPreference API
Branch: master
https://github.com/mongodb/mongo-java-driver/commit/0c0a0acad321dc5b02818aa11f2e041111942925

Comment by zhangchenhui [ 29/Sep/16 ]

the description is good.

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