Skip to content

Commit 8e4f796

Browse files
mp911dechristophstrobl
authored andcommitted
DATAREDIS-1234 - Consistently return List<Long> from LPOS command.
We now convert pipeline/transaction results to List<Long> to ensure a consistent return type. Original Pull Request: #570
1 parent 7f9de71 commit 8e4f796

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,15 +83,17 @@ public List<Long> lPos(byte[] key, byte[] element, @Nullable Integer rank, @Null
8383
if (count != null) {
8484
pipeline(connection.newLettuceResult(getAsyncConnection().lpos(key, element, count, args)));
8585
} else {
86-
pipeline(connection.newLettuceResult(getAsyncConnection().lpos(key, element, args)));
86+
pipeline(
87+
connection.newLettuceResult(getAsyncConnection().lpos(key, element, args), Collections::singletonList));
8788
}
8889
return null;
8990
}
9091
if (isQueueing()) {
9192
if (count != null) {
9293
transaction(connection.newLettuceResult(getAsyncConnection().lpos(key, element, count, args)));
9394
} else {
94-
transaction(connection.newLettuceResult(getAsyncConnection().lpos(key, element, args)));
95+
transaction(
96+
connection.newLettuceResult(getAsyncConnection().lpos(key, element, args), Collections::singletonList));
9597
}
9698
return null;
9799
}

src/test/java/org/springframework/data/redis/connection/AbstractConnectionIntegrationTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1501,9 +1501,9 @@ public void testLPushMultiple() {
15011501
public void lPos() {
15021502

15031503
actual.add(connection.rPush("mylist", "a", "b", "c", "1", "2", "3", "c", "c"));
1504-
actual.add(connection.lPos("mylist", "c"));
1504+
actual.add(connection.lPos("mylist", "c", null, null));
15051505

1506-
assertThat((Long) getResults().get(1)).isEqualTo(2);
1506+
assertThat((List<Long>) getResults().get(1)).containsOnly(2L);
15071507
}
15081508

15091509
@Test // DATAREDIS-1196

0 commit comments

Comments
 (0)