Skip to content

Commit 92a896f

Browse files
mp911dejxblum
authored andcommitted
Use correct output for ZCARD command using LettuceConnection.execute(…).
We now provide a type hint for the ZCARD command. Closes #2473 Original pull request: #2482
1 parent f9caef2 commit 92a896f

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@
5757

5858
import org.apache.commons.logging.Log;
5959
import org.apache.commons.logging.LogFactory;
60-
6160
import org.springframework.beans.BeanUtils;
6261
import org.springframework.core.convert.converter.Converter;
6362
import org.springframework.dao.DataAccessException;
@@ -1088,6 +1087,7 @@ static class TypeHints {
10881087
COMMAND_OUTPUT_TYPE_MAPPING.put(STRLEN, IntegerOutput.class);
10891088
COMMAND_OUTPUT_TYPE_MAPPING.put(TTL, IntegerOutput.class);
10901089
COMMAND_OUTPUT_TYPE_MAPPING.put(ZADD, IntegerOutput.class);
1090+
COMMAND_OUTPUT_TYPE_MAPPING.put(ZCARD, IntegerOutput.class);
10911091
COMMAND_OUTPUT_TYPE_MAPPING.put(ZCOUNT, IntegerOutput.class);
10921092
COMMAND_OUTPUT_TYPE_MAPPING.put(ZINTERSTORE, IntegerOutput.class);
10931093
COMMAND_OUTPUT_TYPE_MAPPING.put(ZRANK, IntegerOutput.class);

src/test/java/org/springframework/data/redis/connection/lettuce/LettuceConnectionIntegrationTests.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323

2424
import org.junit.jupiter.api.Test;
2525
import org.junit.jupiter.api.extension.ExtendWith;
26-
2726
import org.springframework.dao.InvalidDataAccessApiUsageException;
2827
import org.springframework.data.redis.RedisSystemException;
2928
import org.springframework.data.redis.SettingsUtils;
@@ -180,6 +179,16 @@ void testExecuteShouldConvertArrayReplyCorrectly() {
180179
.contains("awesome".getBytes(), "cool".getBytes(), "supercalifragilisticexpialidocious".getBytes());
181180
}
182181

182+
@Test // GH-2473
183+
void testExecuteZcardShouldReturnNumericValue() {
184+
185+
connection.zAdd("spring", 1, "awesome");
186+
connection.zAdd("spring", 1, "cool");
187+
connection.zAdd("spring", 1, "supercalifragilisticexpialidocious");
188+
189+
assertThat(connection.execute("ZCARD", "spring")).isInstanceOf(Long.class).isEqualTo(3L);
190+
}
191+
183192
@SuppressWarnings("unchecked")
184193
@Test
185194
public void testEvalShaArrayBytes() {

0 commit comments

Comments
 (0)