Skip to content

Commit 4652972

Browse files
committed
refactor: fix deprecations and other build warnings
Migrate from deprecated RedisZSetCommands.Range to org.springframework.data.domain.Range in all lexicographic query implementations to fix deprecation warnings marked for removal in Spring Data Redis 3.4.5. enabled. Also added lombok.config to configure Lombok behavior for the tests module. - Fixed text-blocks trailing whitespace warning in MetamodelGeneratorTest - Added AutoService dependency to test annotation processor classpath to resolve "Cannot find annotation method" warning - Updated lombok.config documentation to clarify that @nonnull warnings on primitives are intentional for constructor generation in test fixtures
1 parent 1365657 commit 4652972

File tree

9 files changed

+43
-27
lines changed

9 files changed

+43
-27
lines changed

redis-om-spring/src/main/java/com/redis/om/spring/repository/query/lexicographic/LexicographicQueryExecutor.java

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
import org.apache.commons.logging.Log;
88
import org.apache.commons.logging.LogFactory;
9+
import org.springframework.data.domain.Range;
10+
import org.springframework.data.redis.connection.Limit;
911
import org.springframework.data.util.Pair;
1012
import org.springframework.util.ReflectionUtils;
1113

@@ -176,9 +178,8 @@ private Set<String> executeRangeQuery(String sortedSetKey, QueryClause queryClau
176178
// When doing greater than, we need to exclude exact matches with the same prefix
177179
// Since our format is "value#id", we append a high character to ensure we skip all entries with this prefix
178180
String gtParam = params[0].toString() + "\uffff"; // Unicode max character
179-
Set<String> results = modulesOperations.template().opsForZSet().rangeByLex(sortedSetKey,
180-
org.springframework.data.redis.connection.RedisZSetCommands.Range.range().gt(gtParam),
181-
org.springframework.data.redis.connection.RedisZSetCommands.Limit.unlimited());
181+
Set<String> results = modulesOperations.template().opsForZSet().rangeByLex(sortedSetKey, Range.rightUnbounded(
182+
Range.Bound.exclusive(gtParam)), Limit.unlimited());
182183
logger.debug(String.format("ZRANGEBYLEX %s (%s +inf returned: %s", sortedSetKey, gtParam, results));
183184
return results;
184185

@@ -187,37 +188,33 @@ private Set<String> executeRangeQuery(String sortedSetKey, QueryClause queryClau
187188
// For less than, we need to ensure we don't include the value itself
188189
// Since format is "value#id", we need to get everything before "value#" (excluded)
189190
String ltParam = params[0].toString() + "#"; // Exclude exact matches with this prefix
190-
return modulesOperations.template().opsForZSet().rangeByLex(sortedSetKey,
191-
org.springframework.data.redis.connection.RedisZSetCommands.Range.range().lt(ltParam),
192-
org.springframework.data.redis.connection.RedisZSetCommands.Limit.unlimited());
191+
return modulesOperations.template().opsForZSet().rangeByLex(sortedSetKey, Range.leftUnbounded(Range.Bound
192+
.exclusive(ltParam)), Limit.unlimited());
193193

194194
case TEXT_GREATER_THAN_EQUAL:
195195
case TAG_GREATER_THAN_EQUAL:
196196
// For greater than or equal, we include the value itself
197197
// Since format is "value#id", we start from exactly "value#"
198198
String gteParam = params[0].toString() + "#"; // Include exact matches with this prefix
199-
return modulesOperations.template().opsForZSet().rangeByLex(sortedSetKey,
200-
org.springframework.data.redis.connection.RedisZSetCommands.Range.range().gte(gteParam),
201-
org.springframework.data.redis.connection.RedisZSetCommands.Limit.unlimited());
199+
return modulesOperations.template().opsForZSet().rangeByLex(sortedSetKey, Range.rightUnbounded(Range.Bound
200+
.inclusive(gteParam)), Limit.unlimited());
202201

203202
case TEXT_LESS_THAN_EQUAL:
204203
case TAG_LESS_THAN_EQUAL:
205204
// For less than or equal, we include all values with this prefix
206205
// Since format is "value#id", we use high unicode char to include all IDs with this value
207206
String lteParam = params[0].toString() + "\uffff"; // Include all exact matches with this prefix
208-
return modulesOperations.template().opsForZSet().rangeByLex(sortedSetKey,
209-
org.springframework.data.redis.connection.RedisZSetCommands.Range.range().lte(lteParam),
210-
org.springframework.data.redis.connection.RedisZSetCommands.Limit.unlimited());
207+
return modulesOperations.template().opsForZSet().rangeByLex(sortedSetKey, Range.leftUnbounded(Range.Bound
208+
.inclusive(lteParam)), Limit.unlimited());
211209

212210
case TEXT_BETWEEN:
213211
case TAG_BETWEEN:
214212
// For between queries, we include both bounds
215213
// Start from exactly "minValue#" (inclusive) to "maxValue\uffff" (inclusive of all with maxValue)
216214
String minParam = params[0].toString() + "#";
217215
String maxParam = params[1].toString() + "\uffff";
218-
return modulesOperations.template().opsForZSet().rangeByLex(sortedSetKey,
219-
org.springframework.data.redis.connection.RedisZSetCommands.Range.range().gte(minParam).lte(maxParam),
220-
org.springframework.data.redis.connection.RedisZSetCommands.Limit.unlimited());
216+
return modulesOperations.template().opsForZSet().rangeByLex(sortedSetKey, Range.closed(minParam, maxParam),
217+
Limit.unlimited());
221218

222219
default:
223220
return Collections.emptySet();

redis-om-spring/src/main/java/com/redis/om/spring/search/stream/predicates/lexicographic/LexicographicBetweenPredicate.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
import java.util.Set;
66
import java.util.stream.Collectors;
77

8+
import org.springframework.data.domain.Range;
9+
import org.springframework.data.redis.connection.Limit;
10+
811
import com.redis.om.spring.indexing.RediSearchIndexer;
912
import com.redis.om.spring.metamodel.SearchFieldAccessor;
1013
import com.redis.om.spring.ops.RedisModulesOperations;
@@ -121,9 +124,8 @@ public Node apply(Node root) {
121124
// Start from exactly "minValue#" (inclusive) to "maxValue\uffff" (inclusive of all with maxValue)
122125
String minParam = min.toString() + "#";
123126
String maxParam = max.toString() + "\uffff";
124-
Set<String> matches = rmo.template().opsForZSet().rangeByLex(sortedSetKey,
125-
org.springframework.data.redis.connection.RedisZSetCommands.Range.range().gte(minParam).lte(maxParam),
126-
org.springframework.data.redis.connection.RedisZSetCommands.Limit.unlimited());
127+
Set<String> matches = rmo.template().opsForZSet().rangeByLex(sortedSetKey, Range.closed(minParam, maxParam), Limit
128+
.unlimited());
127129

128130
if (matches == null || matches.isEmpty()) {
129131
// No matches, return a query that matches nothing by using an impossible ID

redis-om-spring/src/main/java/com/redis/om/spring/search/stream/predicates/lexicographic/LexicographicGreaterThanPredicate.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
import java.util.Set;
66
import java.util.stream.Collectors;
77

8+
import org.springframework.data.domain.Range;
9+
import org.springframework.data.redis.connection.Limit;
10+
811
import com.redis.om.spring.indexing.RediSearchIndexer;
912
import com.redis.om.spring.metamodel.SearchFieldAccessor;
1013
import com.redis.om.spring.ops.RedisModulesOperations;
@@ -107,9 +110,8 @@ public Node apply(Node root) {
107110
// For greater than, we need to exclude exact matches with the same prefix
108111
// Since our format is "value#id", we append a high character to ensure we skip all entries with this prefix
109112
String gtParam = value.toString() + "\uffff"; // Unicode max character
110-
Set<String> matches = rmo.template().opsForZSet().rangeByLex(sortedSetKey,
111-
org.springframework.data.redis.connection.RedisZSetCommands.Range.range().gt(gtParam),
112-
org.springframework.data.redis.connection.RedisZSetCommands.Limit.unlimited());
113+
Set<String> matches = rmo.template().opsForZSet().rangeByLex(sortedSetKey, Range.rightUnbounded(Range.Bound
114+
.exclusive(gtParam)), Limit.unlimited());
113115

114116
if (matches == null || matches.isEmpty()) {
115117
// No matches, return a query that matches nothing by using an impossible ID

redis-om-spring/src/main/java/com/redis/om/spring/search/stream/predicates/lexicographic/LexicographicLessThanPredicate.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
import java.util.Set;
66
import java.util.stream.Collectors;
77

8+
import org.springframework.data.domain.Range;
9+
import org.springframework.data.redis.connection.Limit;
10+
811
import com.redis.om.spring.indexing.RediSearchIndexer;
912
import com.redis.om.spring.metamodel.SearchFieldAccessor;
1013
import com.redis.om.spring.ops.RedisModulesOperations;
@@ -107,9 +110,8 @@ public Node apply(Node root) {
107110
// For less than, we need to ensure we don't include the value itself
108111
// Since format is "value#id", we need to get everything before "value#" (excluded)
109112
String ltParam = value.toString() + "#"; // Exclude exact matches with this prefix
110-
Set<String> matches = rmo.template().opsForZSet().rangeByLex(sortedSetKey,
111-
org.springframework.data.redis.connection.RedisZSetCommands.Range.range().lt(ltParam),
112-
org.springframework.data.redis.connection.RedisZSetCommands.Limit.unlimited());
113+
Set<String> matches = rmo.template().opsForZSet().rangeByLex(sortedSetKey, Range.leftUnbounded(Range.Bound
114+
.exclusive(ltParam)), Limit.unlimited());
113115

114116
if (matches == null || matches.isEmpty()) {
115117
// No matches, return a query that matches nothing by using an impossible ID

tests/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ dependencies {
3939
// Important for RedisOM annotation processing!
4040
annotationProcessor project(':redis-om-spring')
4141
testAnnotationProcessor project(':redis-om-spring')
42+
testAnnotationProcessor "com.google.auto.service:auto-service:${autoServiceVersion}"
4243

4344
// Lombok
4445
compileOnly 'org.projectlombok:lombok'

tests/lombok.config

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Lombok configuration for tests module
2+
3+
# Note: @NonNull on primitive types generates warnings but is used intentionally
4+
# to include primitive fields in @RequiredArgsConstructor.
5+
# These warnings are expected and can be ignored as they don't affect functionality.
6+
# The primitives are used in test fixtures where we want them included in the
7+
# constructor for test data setup.
8+
9+
lombok.nonNull.exceptionType = IllegalArgumentException
10+
config.stopBubbling = true

tests/src/test/java/com/redis/om/spring/annotations/LexicographicLessThanDebugTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import org.junit.jupiter.api.BeforeEach;
88
import org.junit.jupiter.api.Test;
99
import org.springframework.beans.factory.annotation.Autowired;
10+
import org.springframework.data.domain.Range;
1011
import org.springframework.data.redis.core.RedisTemplate;
1112

1213
import java.util.Arrays;
@@ -56,7 +57,7 @@ void setup() {
5657

5758
// Test direct ZRANGEBYLEX
5859
Set<String> directQuery = redisTemplate.opsForZSet().rangeByLex(nameLexKey,
59-
org.springframework.data.redis.connection.RedisZSetCommands.Range.range().lt("Product Delta#"));
60+
Range.leftUnbounded(Range.Bound.exclusive("Product Delta#")));
6061
System.out.println("Direct ZRANGEBYLEX LT 'Product Delta#': " + directQuery);
6162
}
6263

tests/src/test/java/com/redis/om/spring/annotations/LexicographicQueryDebugTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import org.junit.jupiter.api.BeforeEach;
1010
import org.junit.jupiter.api.Test;
1111
import org.springframework.beans.factory.annotation.Autowired;
12+
import org.springframework.data.domain.Range;
1213
import org.springframework.data.redis.core.RedisTemplate;
1314

1415
import java.util.Arrays;
@@ -78,7 +79,7 @@ void setup() {
7879

7980
// Test direct sorted set query
8081
Set<String> directQuery = redisTemplate.opsForZSet().rangeByLex(skuLexKey,
81-
org.springframework.data.redis.connection.RedisZSetCommands.Range.range().gt("product002"));
82+
Range.rightUnbounded(Range.Bound.exclusive("product002")));
8283
System.out.println("Direct ZRANGEBYLEX result: " + directQuery);
8384
}
8485

tests/src/test/java/com/redis/om/spring/metamodel/MetamodelGeneratorTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,7 @@ public final class IdOnly$ {
429429
_THIS = new MetamodelField<IdOnly, IdOnly>("__this", IdOnly.class, true);
430430
}
431431
}
432-
""";
432+
""";
433433

434434
assertThat(fileContents).containsIgnoringWhitespaces(expected);
435435
}

0 commit comments

Comments
 (0)