Skip to content

Commit bb57830

Browse files
committed
Fix ZAddArgs.isEmpty.
isEmpty now returns true if empty. Previously, the boolean returns were flipped. Closes #2588
1 parent cb0fb52 commit bb57830

File tree

4 files changed

+39
-3
lines changed

4 files changed

+39
-3
lines changed

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -504,7 +504,7 @@ public boolean contains(Flag flag) {
504504
* @return {@literal true} if no flags set.
505505
*/
506506
public boolean isEmpty() {
507-
return !flags.isEmpty();
507+
return flags.isEmpty();
508508
}
509509

510510
@Override

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -689,7 +689,7 @@ public static GeoUnit toGeoUnit(Metric metric) {
689689
*/
690690
static ZAddParams toZAddParams(ZAddArgs source) {
691691

692-
if (!source.isEmpty()) {
692+
if (source.isEmpty()) {
693693
return new ZAddParams();
694694
}
695695

src/main/java/org/springframework/data/redis/connection/lettuce/LettuceZSetCommands.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -894,7 +894,7 @@ private static io.lettuce.core.ZAddArgs toZAddArgs(ZAddArgs source) {
894894

895895
io.lettuce.core.ZAddArgs target = new io.lettuce.core.ZAddArgs();
896896

897-
if (!source.isEmpty()) {
897+
if (source.isEmpty()) {
898898
return target;
899899
}
900900

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*
2+
* Copyright 2023 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package org.springframework.data.redis.connection;
17+
18+
import static org.assertj.core.api.Assertions.*;
19+
20+
import org.junit.jupiter.api.Test;
21+
import org.springframework.data.redis.connection.RedisZSetCommands.ZAddArgs;
22+
23+
/**
24+
* Unit tests for {@link RedisZSetCommands}.
25+
*
26+
* @author Mark Paluch
27+
*/
28+
class RedisZSetCommandsUnitTests {
29+
30+
@Test // GH-2588
31+
void zAddArgsShouldReportEmpty() {
32+
33+
assertThat(ZAddArgs.empty().isEmpty()).isTrue();
34+
assertThat(ZAddArgs.ifExists().isEmpty()).isFalse();
35+
}
36+
}

0 commit comments

Comments
 (0)