diff --git a/driver-core/src/main/com/mongodb/ReadPreference.java b/driver-core/src/main/com/mongodb/ReadPreference.java index 0d5267f384..036a4de5df 100644 --- a/driver-core/src/main/com/mongodb/ReadPreference.java +++ b/driver-core/src/main/com/mongodb/ReadPreference.java @@ -98,7 +98,9 @@ public abstract class ReadPreference { * @return a new ReadPreference instance with hedge options * @since 4.1 * @mongodb.server.release 4.4 + * @deprecated As of MongoDB 8.1, the server ignores the option and periodically logs a warning */ + @Deprecated public abstract ReadPreference withHedgeOptions(ReadPreferenceHedgeOptions hedgeOptions); /** @@ -682,6 +684,7 @@ public TaggableReadPreference withMaxStalenessMS(final Long maxStalenessMS, fina throw new UnsupportedOperationException("Primary read preference can not also specify max staleness"); } + @Deprecated @Override public TaggableReadPreference withHedgeOptions(final ReadPreferenceHedgeOptions hedgeOptions) { throw new UnsupportedOperationException("Primary read preference can not also specify hedge"); diff --git a/driver-core/src/main/com/mongodb/ReadPreferenceHedgeOptions.java b/driver-core/src/main/com/mongodb/ReadPreferenceHedgeOptions.java index 527455fdb9..655f747c80 100644 --- a/driver-core/src/main/com/mongodb/ReadPreferenceHedgeOptions.java +++ b/driver-core/src/main/com/mongodb/ReadPreferenceHedgeOptions.java @@ -25,7 +25,9 @@ * * @since 4.1 * @mongodb.server.release 4.4 + * @deprecated As of MongoDB 8.1, the server ignores the option and periodically logs a warning */ +@Deprecated @Immutable public final class ReadPreferenceHedgeOptions { private final boolean enabled; diff --git a/driver-core/src/main/com/mongodb/TaggableReadPreference.java b/driver-core/src/main/com/mongodb/TaggableReadPreference.java index d92afa128f..426dc69e96 100644 --- a/driver-core/src/main/com/mongodb/TaggableReadPreference.java +++ b/driver-core/src/main/com/mongodb/TaggableReadPreference.java @@ -54,6 +54,7 @@ public abstract class TaggableReadPreference extends ReadPreference { private final List tagSetList = new ArrayList<>(); private final Long maxStalenessMS; + @SuppressWarnings("deprecation") private final ReadPreferenceHedgeOptions hedgeOptions; TaggableReadPreference() { @@ -61,6 +62,7 @@ public abstract class TaggableReadPreference extends ReadPreference { this.hedgeOptions = null; } + @SuppressWarnings("deprecation") TaggableReadPreference(final List tagSetList, @Nullable final Long maxStaleness, final TimeUnit timeUnit, @Nullable final ReadPreferenceHedgeOptions hedgeOptions) { notNull("tagSetList", tagSetList); @@ -80,6 +82,7 @@ public abstract class TaggableReadPreference extends ReadPreference { @Override public abstract TaggableReadPreference withMaxStalenessMS(Long maxStalenessMS, TimeUnit timeUnit); + @Deprecated @Override public abstract TaggableReadPreference withHedgeOptions(ReadPreferenceHedgeOptions hedgeOptions); @@ -146,7 +149,9 @@ public Long getMaxStaleness(final TimeUnit timeUnit) { * @return the hedge options * @mongodb.server.release 4.4 * @since 4.1 + * @deprecated As of MongoDB 8.1, the server ignores the option and periodically logs a warning */ + @Deprecated @Nullable public ReadPreferenceHedgeOptions getHedgeOptions() { return hedgeOptions; @@ -327,6 +332,7 @@ static class SecondaryReadPreference extends TaggableReadPreference { this(tagSetList, maxStaleness, timeUnit, null); } + @SuppressWarnings("deprecation") SecondaryReadPreference(final List tagSetList, @Nullable final Long maxStaleness, final TimeUnit timeUnit, @Nullable final ReadPreferenceHedgeOptions hedgeOptions) { super(tagSetList, maxStaleness, timeUnit, hedgeOptions); @@ -349,6 +355,7 @@ public TaggableReadPreference withMaxStalenessMS(@Nullable final Long maxStalene return new SecondaryReadPreference(getTagSetList(), maxStaleness, timeUnit, getHedgeOptions()); } + @Deprecated @Override public TaggableReadPreference withHedgeOptions(final ReadPreferenceHedgeOptions hedgeOptions) { return new SecondaryReadPreference(getTagSetList(), getMaxStaleness(MILLISECONDS), MILLISECONDS, hedgeOptions); @@ -388,6 +395,7 @@ static class SecondaryPreferredReadPreference extends SecondaryReadPreference { this(tagSetList, maxStaleness, timeUnit, null); } + @SuppressWarnings("deprecation") SecondaryPreferredReadPreference(final List tagSetList, @Nullable final Long maxStaleness, final TimeUnit timeUnit, @Nullable final ReadPreferenceHedgeOptions hedgeOptions) { super(tagSetList, maxStaleness, timeUnit, hedgeOptions); @@ -410,6 +418,7 @@ public TaggableReadPreference withMaxStalenessMS(@Nullable final Long maxStalene return new SecondaryPreferredReadPreference(getTagSetList(), maxStaleness, timeUnit, getHedgeOptions()); } + @Deprecated @Override public TaggableReadPreference withHedgeOptions(final ReadPreferenceHedgeOptions hedgeOptions) { return new SecondaryPreferredReadPreference(getTagSetList(), getMaxStaleness(MILLISECONDS), MILLISECONDS, hedgeOptions); @@ -441,6 +450,7 @@ static class NearestReadPreference extends TaggableReadPreference { this(tagSetList, maxStaleness, timeUnit, null); } + @SuppressWarnings("deprecation") NearestReadPreference(final List tagSetList, @Nullable final Long maxStaleness, final TimeUnit timeUnit, @Nullable final ReadPreferenceHedgeOptions hedgeOptions) { super(tagSetList, maxStaleness, timeUnit, hedgeOptions); @@ -463,6 +473,7 @@ public TaggableReadPreference withMaxStalenessMS(@Nullable final Long maxStalene return new NearestReadPreference(getTagSetList(), maxStaleness, timeUnit, getHedgeOptions()); } + @Deprecated @Override public TaggableReadPreference withHedgeOptions(final ReadPreferenceHedgeOptions hedgeOptions) { return new NearestReadPreference(getTagSetList(), getMaxStaleness(MILLISECONDS), MILLISECONDS, hedgeOptions); @@ -503,6 +514,7 @@ static class PrimaryPreferredReadPreference extends SecondaryReadPreference { this(tagSetList, maxStaleness, timeUnit, null); } + @SuppressWarnings("deprecation") PrimaryPreferredReadPreference(final List tagSetList, @Nullable final Long maxStaleness, final TimeUnit timeUnit, @Nullable final ReadPreferenceHedgeOptions hedgeOptions) { super(tagSetList, maxStaleness, timeUnit, hedgeOptions); @@ -525,6 +537,7 @@ public TaggableReadPreference withMaxStalenessMS(@Nullable final Long maxStalene return new PrimaryPreferredReadPreference(getTagSetList(), maxStaleness, timeUnit, getHedgeOptions()); } + @Deprecated @Override public TaggableReadPreference withHedgeOptions(final ReadPreferenceHedgeOptions hedgeOptions) { return new PrimaryPreferredReadPreference(getTagSetList(), getMaxStaleness(MILLISECONDS), MILLISECONDS, hedgeOptions);