@@ -54,13 +54,15 @@ public abstract class TaggableReadPreference extends ReadPreference {
5454
5555 private final List <TagSet > tagSetList = new ArrayList <>();
5656 private final Long maxStalenessMS ;
57+ @ SuppressWarnings ("deprecation" )
5758 private final ReadPreferenceHedgeOptions hedgeOptions ;
5859
5960 TaggableReadPreference () {
6061 this .maxStalenessMS = null ;
6162 this .hedgeOptions = null ;
6263 }
6364
65+ @ SuppressWarnings ("deprecation" )
6466 TaggableReadPreference (final List <TagSet > tagSetList , @ Nullable final Long maxStaleness , final TimeUnit timeUnit ,
6567 @ Nullable final ReadPreferenceHedgeOptions hedgeOptions ) {
6668 notNull ("tagSetList" , tagSetList );
@@ -80,6 +82,7 @@ public abstract class TaggableReadPreference extends ReadPreference {
8082 @ Override
8183 public abstract TaggableReadPreference withMaxStalenessMS (Long maxStalenessMS , TimeUnit timeUnit );
8284
85+ @ Deprecated
8386 @ Override
8487 public abstract TaggableReadPreference withHedgeOptions (ReadPreferenceHedgeOptions hedgeOptions );
8588
@@ -146,7 +149,9 @@ public Long getMaxStaleness(final TimeUnit timeUnit) {
146149 * @return the hedge options
147150 * @mongodb.server.release 4.4
148151 * @since 4.1
152+ * @deprecated As of MongoDB 8.1, the server ignores the option and periodically logs a warning
149153 */
154+ @ Deprecated
150155 @ Nullable
151156 public ReadPreferenceHedgeOptions getHedgeOptions () {
152157 return hedgeOptions ;
@@ -327,6 +332,7 @@ static class SecondaryReadPreference extends TaggableReadPreference {
327332 this (tagSetList , maxStaleness , timeUnit , null );
328333 }
329334
335+ @ SuppressWarnings ("deprecation" )
330336 SecondaryReadPreference (final List <TagSet > tagSetList , @ Nullable final Long maxStaleness , final TimeUnit timeUnit ,
331337 @ Nullable final ReadPreferenceHedgeOptions hedgeOptions ) {
332338 super (tagSetList , maxStaleness , timeUnit , hedgeOptions );
@@ -349,6 +355,7 @@ public TaggableReadPreference withMaxStalenessMS(@Nullable final Long maxStalene
349355 return new SecondaryReadPreference (getTagSetList (), maxStaleness , timeUnit , getHedgeOptions ());
350356 }
351357
358+ @ Deprecated
352359 @ Override
353360 public TaggableReadPreference withHedgeOptions (final ReadPreferenceHedgeOptions hedgeOptions ) {
354361 return new SecondaryReadPreference (getTagSetList (), getMaxStaleness (MILLISECONDS ), MILLISECONDS , hedgeOptions );
@@ -388,6 +395,7 @@ static class SecondaryPreferredReadPreference extends SecondaryReadPreference {
388395 this (tagSetList , maxStaleness , timeUnit , null );
389396 }
390397
398+ @ SuppressWarnings ("deprecation" )
391399 SecondaryPreferredReadPreference (final List <TagSet > tagSetList , @ Nullable final Long maxStaleness , final TimeUnit timeUnit ,
392400 @ Nullable final ReadPreferenceHedgeOptions hedgeOptions ) {
393401 super (tagSetList , maxStaleness , timeUnit , hedgeOptions );
@@ -410,6 +418,7 @@ public TaggableReadPreference withMaxStalenessMS(@Nullable final Long maxStalene
410418 return new SecondaryPreferredReadPreference (getTagSetList (), maxStaleness , timeUnit , getHedgeOptions ());
411419 }
412420
421+ @ Deprecated
413422 @ Override
414423 public TaggableReadPreference withHedgeOptions (final ReadPreferenceHedgeOptions hedgeOptions ) {
415424 return new SecondaryPreferredReadPreference (getTagSetList (), getMaxStaleness (MILLISECONDS ), MILLISECONDS , hedgeOptions );
@@ -441,6 +450,7 @@ static class NearestReadPreference extends TaggableReadPreference {
441450 this (tagSetList , maxStaleness , timeUnit , null );
442451 }
443452
453+ @ SuppressWarnings ("deprecation" )
444454 NearestReadPreference (final List <TagSet > tagSetList , @ Nullable final Long maxStaleness , final TimeUnit timeUnit ,
445455 @ Nullable final ReadPreferenceHedgeOptions hedgeOptions ) {
446456 super (tagSetList , maxStaleness , timeUnit , hedgeOptions );
@@ -463,6 +473,7 @@ public TaggableReadPreference withMaxStalenessMS(@Nullable final Long maxStalene
463473 return new NearestReadPreference (getTagSetList (), maxStaleness , timeUnit , getHedgeOptions ());
464474 }
465475
476+ @ Deprecated
466477 @ Override
467478 public TaggableReadPreference withHedgeOptions (final ReadPreferenceHedgeOptions hedgeOptions ) {
468479 return new NearestReadPreference (getTagSetList (), getMaxStaleness (MILLISECONDS ), MILLISECONDS , hedgeOptions );
@@ -503,6 +514,7 @@ static class PrimaryPreferredReadPreference extends SecondaryReadPreference {
503514 this (tagSetList , maxStaleness , timeUnit , null );
504515 }
505516
517+ @ SuppressWarnings ("deprecation" )
506518 PrimaryPreferredReadPreference (final List <TagSet > tagSetList , @ Nullable final Long maxStaleness , final TimeUnit timeUnit ,
507519 @ Nullable final ReadPreferenceHedgeOptions hedgeOptions ) {
508520 super (tagSetList , maxStaleness , timeUnit , hedgeOptions );
@@ -525,6 +537,7 @@ public TaggableReadPreference withMaxStalenessMS(@Nullable final Long maxStalene
525537 return new PrimaryPreferredReadPreference (getTagSetList (), maxStaleness , timeUnit , getHedgeOptions ());
526538 }
527539
540+ @ Deprecated
528541 @ Override
529542 public TaggableReadPreference withHedgeOptions (final ReadPreferenceHedgeOptions hedgeOptions ) {
530543 return new PrimaryPreferredReadPreference (getTagSetList (), getMaxStaleness (MILLISECONDS ), MILLISECONDS , hedgeOptions );
0 commit comments