Skip to content

Commit 1ad01d4

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

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
@@ -313,7 +313,7 @@ public boolean contains(Flag flag) {
313313
* @return {@literal true} if no flags set.
314314
*/
315315
public boolean isEmpty() {
316-
return !flags.isEmpty();
316+
return flags.isEmpty();
317317
}
318318

319319
@Override

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -618,7 +618,7 @@ public static GeoUnit toGeoUnit(Metric metric) {
618618
*/
619619
static ZAddParams toZAddParams(ZAddArgs source) {
620620

621-
if (!source.isEmpty()) {
621+
if (source.isEmpty()) {
622622
return new ZAddParams();
623623
}
624624

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

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

755755
io.lettuce.core.ZAddArgs target = new io.lettuce.core.ZAddArgs();
756756

757-
if (!source.isEmpty()) {
757+
if (source.isEmpty()) {
758758
return target;
759759
}
760760

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)