Skip to content

Commit baa5cf2

Browse files
committed
Remove deprecated API.
Closes #3176
1 parent e7927d2 commit baa5cf2

23 files changed

+78
-700
lines changed

src/main/java/org/springframework/data/redis/cache/RedisCacheConfiguration.java

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -375,21 +375,6 @@ public SerializationPair<Object> getValueSerializationPair() {
375375
return this.valueSerializationPair;
376376
}
377377

378-
/**
379-
* Returns a computed {@link Duration TTL expiration timeout} based on cache entry key/value if a {@link TtlFunction}
380-
* was confiugred using {@link #entryTtl(TtlFunction)}.
381-
* <p>
382-
* Otherwise, returns the user-provided, fixed {@link Duration} if {@link #entryTtl(Duration)} was called during cache
383-
* configuration.
384-
*
385-
* @return the configured {@link Duration TTL expiration}.
386-
* @deprecated since 3.2. Use {@link #getTtlFunction()} instead.
387-
*/
388-
@Deprecated(since = "3.2")
389-
public Duration getTtl() {
390-
return getTtlFunction().getTimeToLive(Object.class, null);
391-
}
392-
393378
/**
394379
* Gets the {@link TtlFunction} used to compute a cache key {@literal time-to-live (TTL) expiration}.
395380
*

src/main/java/org/springframework/data/redis/cache/RedisCacheManager.java

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -225,16 +225,6 @@ public RedisCacheManager(RedisCacheWriter cacheWriter, RedisCacheConfiguration d
225225
this.initialCacheConfiguration.putAll(initialCacheConfigurations);
226226
}
227227

228-
/**
229-
* @deprecated since 3.2. Use {@link RedisCacheManager#RedisCacheManager(RedisCacheWriter, RedisCacheConfiguration, boolean, Map)} instead.
230-
*/
231-
@Deprecated(since = "3.2")
232-
public RedisCacheManager(RedisCacheWriter cacheWriter, RedisCacheConfiguration defaultCacheConfiguration,
233-
Map<String, RedisCacheConfiguration> initialCacheConfigurations, boolean allowRuntimeCacheCreation) {
234-
235-
this(cacheWriter, defaultCacheConfiguration, allowRuntimeCacheCreation, initialCacheConfigurations);
236-
}
237-
238228
/**
239229
* Factory method returning a {@literal Builder} used to construct and configure a {@link RedisCacheManager}.
240230
*

src/main/java/org/springframework/data/redis/connection/NamedNode.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,5 @@ public interface NamedNode {
2828
*/
2929
@Nullable
3030
String getName();
31+
3132
}

src/main/java/org/springframework/data/redis/connection/RedisClusterConfiguration.java

Lines changed: 12 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,11 @@
1717

1818
import java.util.Collection;
1919
import java.util.Collections;
20-
import java.util.HashMap;
2120
import java.util.LinkedHashSet;
22-
import java.util.Map;
2321
import java.util.Set;
2422

2523
import org.jspecify.annotations.Nullable;
26-
import org.springframework.core.env.MapPropertySource;
24+
2725
import org.springframework.core.env.PropertySource;
2826
import org.springframework.data.redis.connection.RedisConfiguration.ClusterConfiguration;
2927
import org.springframework.util.Assert;
@@ -70,7 +68,9 @@ public RedisClusterConfiguration() {}
7068
* @param clusterNodes must not be {@literal null}.
7169
*/
7270
public RedisClusterConfiguration(Collection<String> clusterNodes) {
73-
initialize(new MapPropertySource("RedisClusterConfiguration", asMap(clusterNodes, -1)));
71+
for (String hostAndPort : clusterNodes) {
72+
addClusterNode(RedisNode.fromString(hostAndPort));
73+
}
7474
}
7575

7676
/**
@@ -83,45 +83,27 @@ public RedisClusterConfiguration(Collection<String> clusterNodes) {
8383
* </pre>
8484
*
8585
* @param propertySource must not be {@literal null}.
86-
* @deprecated since 3.3, use {@link RedisSentinelConfiguration#of(PropertySource)} instead. This constructor will be
87-
* made private in the next major release.
86+
* @return a new {@link RedisClusterConfiguration} configured from the given {@link PropertySource}.
87+
* @since 3.3
8888
*/
89-
@Deprecated(since = "3.3")
90-
public RedisClusterConfiguration(PropertySource<?> propertySource) {
91-
initialize(propertySource);
92-
}
93-
94-
private void initialize(PropertySource<?> propertySource) {
89+
public static RedisClusterConfiguration of(PropertySource<?> propertySource) {
9590

9691
Assert.notNull(propertySource, "PropertySource must not be null");
9792

93+
RedisClusterConfiguration configuration = new RedisClusterConfiguration();
94+
9895
if (propertySource.containsProperty(REDIS_CLUSTER_NODES_CONFIG_PROPERTY)) {
9996

10097
Object redisClusterNodes = propertySource.getProperty(REDIS_CLUSTER_NODES_CONFIG_PROPERTY);
101-
appendClusterNodes(StringUtils.commaDelimitedListToSet(String.valueOf(redisClusterNodes)));
98+
configuration.appendClusterNodes(StringUtils.commaDelimitedListToSet(String.valueOf(redisClusterNodes)));
10299
}
103100
if (propertySource.containsProperty(REDIS_CLUSTER_MAX_REDIRECTS_CONFIG_PROPERTY)) {
104101

105102
Object clusterMaxRedirects = propertySource.getProperty(REDIS_CLUSTER_MAX_REDIRECTS_CONFIG_PROPERTY);
106-
this.maxRedirects = NumberUtils.parseNumber(String.valueOf(clusterMaxRedirects), Integer.class);
103+
configuration.setMaxRedirects(NumberUtils.parseNumber(String.valueOf(clusterMaxRedirects), Integer.class));
107104
}
108-
}
109105

110-
/**
111-
* Creates a new {@link RedisClusterConfiguration} looking up configuration values from the given
112-
* {@link PropertySource}.
113-
*
114-
* <pre class="code">
115-
* spring.redis.cluster.nodes=127.0.0.1:23679,127.0.0.1:23680,127.0.0.1:23681
116-
* spring.redis.cluster.max-redirects=3
117-
* </pre>
118-
*
119-
* @param propertySource must not be {@literal null}.
120-
* @return a new {@link RedisClusterConfiguration} configured from the given {@link PropertySource}.
121-
* @since 3.3
122-
*/
123-
public static RedisClusterConfiguration of(PropertySource<?> propertySource) {
124-
return new RedisClusterConfiguration(propertySource);
106+
return configuration;
125107
}
126108

127109
private void appendClusterNodes(Set<String> hostAndPorts) {
@@ -247,24 +229,4 @@ public int hashCode() {
247229
return result;
248230
}
249231

250-
/**
251-
* @param clusterHostAndPorts must not be {@literal null} or empty.
252-
* @param redirects the max number of redirects to follow.
253-
* @return cluster config map with properties.
254-
*/
255-
private static Map<String, Object> asMap(Collection<String> clusterHostAndPorts, int redirects) {
256-
257-
Assert.notNull(clusterHostAndPorts, "ClusterHostAndPorts must not be null");
258-
Assert.noNullElements(clusterHostAndPorts, "ClusterHostAndPorts must not contain null elements");
259-
260-
Map<String, Object> map = new HashMap<>();
261-
262-
map.put(REDIS_CLUSTER_NODES_CONFIG_PROPERTY, StringUtils.collectionToCommaDelimitedString(clusterHostAndPorts));
263-
264-
if (redirects >= 0) {
265-
map.put(REDIS_CLUSTER_MAX_REDIRECTS_CONFIG_PROPERTY, redirects);
266-
}
267-
268-
return map;
269-
}
270232
}

src/main/java/org/springframework/data/redis/connection/RedisSentinelConfiguration.java

Lines changed: 24 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
import java.util.Set;
2525

2626
import org.jspecify.annotations.Nullable;
27-
import org.springframework.core.env.MapPropertySource;
27+
2828
import org.springframework.core.env.PropertySource;
2929
import org.springframework.data.redis.connection.RedisConfiguration.SentinelConfiguration;
3030
import org.springframework.util.Assert;
@@ -62,7 +62,7 @@ public class RedisSentinelConfiguration implements RedisConfiguration, SentinelC
6262
private RedisPassword dataNodePassword = RedisPassword.none();
6363
private RedisPassword sentinelPassword = RedisPassword.none();
6464

65-
private final Set<RedisNode> sentinels;
65+
private final Set<RedisNode> sentinels = new LinkedHashSet<>();
6666

6767
private @Nullable String dataNodeUsername = null;
6868
private @Nullable String sentinelUsername = null;
@@ -71,7 +71,6 @@ public class RedisSentinelConfiguration implements RedisConfiguration, SentinelC
7171
* Creates a new, default {@link RedisSentinelConfiguration}.
7272
*/
7373
public RedisSentinelConfiguration() {
74-
this(new MapPropertySource("RedisSentinelConfiguration", Collections.emptyMap()));
7574
}
7675

7776
/**
@@ -86,60 +85,60 @@ public RedisSentinelConfiguration() {
8685
* @since 1.5
8786
*/
8887
public RedisSentinelConfiguration(String master, Set<String> sentinelHostAndPorts) {
89-
this(new MapPropertySource("RedisSentinelConfiguration", asMap(master, sentinelHostAndPorts)));
88+
89+
Assert.notNull(master, "Sentinel master must not be null");
90+
Assert.notNull(sentinelHostAndPorts, "Sentinel nodes must not be null");
91+
92+
this.master = new SentinelMasterId(master);
93+
94+
for (String hostAndPort : sentinelHostAndPorts) {
95+
addSentinel(RedisNode.fromString(hostAndPort, RedisNode.DEFAULT_SENTINEL_PORT));
96+
}
9097
}
9198

9299
/**
93-
* Creates a new {@link RedisSentinelConfiguration} looking up configuration values from the given
94-
* {@link PropertySource}.
95-
*
96-
* <pre class="code">
97-
* spring.redis.sentinel.master=myMaster
98-
* spring.redis.sentinel.nodes=127.0.0.1:23679,127.0.0.1:23680,127.0.0.1:23681
99-
* </pre>
100+
* Construct a new {@link RedisSentinelConfiguration} from the given {@link PropertySource}.
100101
*
101102
* @param propertySource must not be {@literal null}.
102-
* @since 1.5
103-
* @deprecated since 3.3, use {@link RedisSentinelConfiguration#of(PropertySource)} instead. This constructor will be
104-
* made private in the next major release.
103+
* @return a new {@link RedisSentinelConfiguration} configured from the given {@link PropertySource}.
104+
* @since 3.3
105105
*/
106-
@Deprecated(since = "3.3")
107-
public RedisSentinelConfiguration(PropertySource<?> propertySource) {
106+
public static RedisSentinelConfiguration of(PropertySource<?> propertySource) {
108107

109108
Assert.notNull(propertySource, "PropertySource must not be null");
110109

111-
this.sentinels = new LinkedHashSet<>();
110+
RedisSentinelConfiguration configuration = new RedisSentinelConfiguration();
112111

113112
if (propertySource.containsProperty(REDIS_SENTINEL_MASTER_CONFIG_PROPERTY)) {
114113
String sentinelMaster = String.valueOf(propertySource.getProperty(REDIS_SENTINEL_MASTER_CONFIG_PROPERTY));
115-
this.setMaster(sentinelMaster);
114+
configuration.setMaster(sentinelMaster);
116115
}
117116

118117
if (propertySource.containsProperty(REDIS_SENTINEL_NODES_CONFIG_PROPERTY)) {
119118
String sentinelNodes = String.valueOf(propertySource.getProperty(REDIS_SENTINEL_NODES_CONFIG_PROPERTY));
120-
appendSentinels(commaDelimitedListToSet(sentinelNodes));
119+
configuration.appendSentinels(commaDelimitedListToSet(sentinelNodes));
121120
}
122121

123122
if (propertySource.containsProperty(REDIS_SENTINEL_PASSWORD_CONFIG_PROPERTY)) {
124123
String sentinelPassword = String.valueOf(propertySource.getProperty(REDIS_SENTINEL_PASSWORD_CONFIG_PROPERTY));
125-
this.setSentinelPassword(sentinelPassword);
124+
configuration.setSentinelPassword(sentinelPassword);
126125
}
127126

128127
if (propertySource.containsProperty(REDIS_SENTINEL_USERNAME_CONFIG_PROPERTY)) {
129128
String sentinelUsername = String.valueOf(propertySource.getProperty(REDIS_SENTINEL_USERNAME_CONFIG_PROPERTY));
130-
this.setSentinelUsername(sentinelUsername);
129+
configuration.setSentinelUsername(sentinelUsername);
131130
}
132131

133132
if (propertySource.containsProperty(REDIS_SENTINEL_DATA_NODE_USERNAME_CONFIG_PROPERTY)) {
134133
String dataNodeUsername = String
135134
.valueOf(propertySource.getProperty(REDIS_SENTINEL_DATA_NODE_USERNAME_CONFIG_PROPERTY));
136-
this.setUsername(dataNodeUsername);
135+
configuration.setUsername(dataNodeUsername);
137136
}
138137

139138
if (propertySource.containsProperty(REDIS_SENTINEL_DATA_NODE_PASSWORD_CONFIG_PROPERTY)) {
140139
String dataNodePassword = String
141140
.valueOf(propertySource.getProperty(REDIS_SENTINEL_DATA_NODE_PASSWORD_CONFIG_PROPERTY));
142-
this.setPassword(dataNodePassword);
141+
configuration.setPassword(dataNodePassword);
143142
}
144143

145144
if (propertySource.containsProperty(REDIS_SENTINEL_DATA_NODE_DATABASE_CONFIG_PROPERTY)) {
@@ -151,19 +150,10 @@ public RedisSentinelConfiguration(PropertySource<?> propertySource) {
151150
} catch (NumberFormatException ex) {
152151
throw new IllegalArgumentException("Invalid DB index '%s'; integer required".formatted(databaseSource));
153152
}
154-
this.setDatabase(database);
153+
configuration.setDatabase(database);
155154
}
156-
}
157155

158-
/**
159-
* Construct a new {@link RedisSentinelConfiguration} from the given {@link PropertySource}.
160-
*
161-
* @param propertySource must not be {@literal null}.
162-
* @return a new {@link RedisSentinelConfiguration} configured from the given {@link PropertySource}.
163-
* @since 3.3
164-
*/
165-
public static RedisSentinelConfiguration of(PropertySource<?> propertySource) {
166-
return new RedisSentinelConfiguration(propertySource);
156+
return configuration;
167157
}
168158

169159
/**

src/main/java/org/springframework/data/redis/connection/SentinelMasterId.java

Lines changed: 3 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -15,50 +15,28 @@
1515
*/
1616
package org.springframework.data.redis.connection;
1717

18-
import org.jspecify.annotations.NonNull;
19-
import org.jspecify.annotations.Nullable;
2018
import org.springframework.util.Assert;
21-
import org.springframework.util.ObjectUtils;
2219

2320
/**
2421
* Simple {@link NamedNode}.
2522
*
2623
* @author Mark Paluch
2724
* @since 2.5.3
2825
*/
29-
class SentinelMasterId implements NamedNode {
26+
record SentinelMasterId(String name) implements NamedNode {
3027

31-
private final String name;
32-
33-
public SentinelMasterId(String name) {
28+
SentinelMasterId {
3429
Assert.hasText(name, "Sentinel Master Id must not be null or empty");
35-
this.name = name;
3630
}
3731

38-
@NonNull
3932
@Override
4033
public String getName() {
4134
return name;
4235
}
4336

4437
@Override
4538
public String toString() {
46-
return getName();
47-
}
48-
49-
@Override
50-
public boolean equals(@Nullable Object o) {
51-
if (this == o) {
52-
return true;
53-
}
54-
if (!(o instanceof SentinelMasterId that)) {
55-
return false;
56-
}
57-
return ObjectUtils.nullSafeEquals(name, that.name);
39+
return name();
5840
}
5941

60-
@Override
61-
public int hashCode() {
62-
return ObjectUtils.nullSafeHashCode(name);
63-
}
6442
}

src/main/java/org/springframework/data/redis/connection/jedis/JedisClusterConnection.java

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -879,21 +879,6 @@ public ClusterTopology getTopology() {
879879
"Could not retrieve cluster information; CLUSTER NODES returned with error" + stringBuilder);
880880
}
881881

882-
/**
883-
* Returns whether {@link #getTopology()} should return the cached {@link ClusterTopology}. Uses a time-based
884-
* caching.
885-
*
886-
* @return {@literal true} to use the cached {@link ClusterTopology}; {@literal false} to fetch a new cluster
887-
* topology.
888-
* @see #JedisClusterTopologyProvider(JedisCluster, Duration)
889-
* @since 2.2
890-
* @deprecated since 3.3.4, use {@link #shouldUseCachedValue(JedisClusterTopology)} instead.
891-
*/
892-
@Deprecated(since = "3.3.4", forRemoval = true)
893-
protected boolean shouldUseCachedValue() {
894-
return shouldUseCachedValue(cached);
895-
}
896-
897882
/**
898883
* Returns whether {@link #getTopology()} should return the cached {@link JedisClusterTopology}. Uses a time-based
899884
* caching.

src/main/java/org/springframework/data/redis/core/BoundSetOperations.java

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -167,19 +167,6 @@ public interface BoundSetOperations<K, V> extends BoundKeyOperations<K> {
167167
*/
168168
void unionAndStore(@NonNull Collection<@NonNull K> keys, @NonNull K destKey);
169169

170-
/**
171-
* Diff all sets for given the bound key and {@code key}.
172-
*
173-
* @param key must not be {@literal null}.
174-
* @return {@literal null} when used in pipeline / transaction.
175-
* @see <a href="https://redis.io/commands/sdiff">Redis Documentation: SDIFF</a>
176-
* @deprecated since 3.0, use {@link #difference(Object)} instead to follow a consistent method naming scheme.
177-
*/
178-
@Deprecated(since = "3.0")
179-
default Set<@NonNull V> diff(@NonNull K key) {
180-
return difference(key);
181-
}
182-
183170
/**
184171
* Diff all sets for given the bound key and {@code key}.
185172
*
@@ -190,19 +177,6 @@ public interface BoundSetOperations<K, V> extends BoundKeyOperations<K> {
190177
*/
191178
Set<@NonNull V> difference(@NonNull K key);
192179

193-
/**
194-
* Diff all sets for given the bound key and {@code keys}.
195-
*
196-
* @param keys must not be {@literal null}.
197-
* @return {@literal null} when used in pipeline / transaction.
198-
* @see <a href="https://redis.io/commands/sdiff">Redis Documentation: SDIFF</a>
199-
* @deprecated since 3.0, use {@link #difference(Collection)} instead to follow a consistent method naming scheme.
200-
*/
201-
@Deprecated(since = "3.0")
202-
default Set<@NonNull V> diff(@NonNull Collection<@NonNull K> keys) {
203-
return difference(keys);
204-
}
205-
206180
/**
207181
* Diff all sets for given the bound key and {@code keys}.
208182
*

0 commit comments

Comments
 (0)