Skip to content

Commit

Permalink
Java: Fix lpopCount null handling (#3025)
Browse files Browse the repository at this point in the history
Java: Fix lpopCount null handling
---------

Signed-off-by: James Xin <[email protected]>
  • Loading branch information
jamesx-improving authored Jan 29, 2025
1 parent dc79586 commit 17a91b2
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

* Node: Fix `zrangeWithScores` (disallow `RangeByLex` as it is not supported) ([#2926](https://github.com/valkey-io/valkey-glide/pull/2926))
* Core: improve fix in #2381 ([#2929](https://github.com/valkey-io/valkey-glide/pull/2929))
* Java: Fix `lpopCount` null handling ([#3025](https://github.com/valkey-io/valkey-glide/pull/3025))

#### Operational Enhancements

Expand Down
4 changes: 2 additions & 2 deletions java/client/src/main/java/glide/api/BaseClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -1384,15 +1384,15 @@ public CompletableFuture<String[]> lpopCount(@NonNull String key, long count) {
return commandManager.submitNewCommand(
LPop,
new String[] {key, Long.toString(count)},
response -> castArray(handleArrayResponse(response), String.class));
response -> castArray(handleArrayOrNullResponse(response), String.class));
}

@Override
public CompletableFuture<GlideString[]> lpopCount(@NonNull GlideString key, long count) {
return commandManager.submitNewCommand(
LPop,
new GlideString[] {key, gs(Long.toString(count))},
response -> castArray(handleArrayResponseBinary(response), GlideString.class));
response -> castArray(handleArrayOrNullResponseBinary(response), GlideString.class));
}

@Override
Expand Down
2 changes: 2 additions & 0 deletions java/integTest/src/test/java/glide/SharedCommandTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -1695,6 +1695,7 @@ public void lpush_lpop_lrange_existing_non_existing_key(BaseClient client) {
assertArrayEquals(new String[] {"value2", "value3"}, client.lpopCount(key, 2).get());
assertArrayEquals(new String[] {}, client.lrange("non_existing_key", 0, -1).get());
assertNull(client.lpop("non_existing_key").get());
assertNull(client.lpopCount("non_existing_key", 2).get());
}

@SneakyThrows
Expand All @@ -1714,6 +1715,7 @@ public void lpush_lpop_lrange_binary_existing_non_existing_key(BaseClient client
new GlideString[] {gs("value2"), gs("value3")}, client.lpopCount(key, 2).get());
assertArrayEquals(new GlideString[] {}, client.lrange(gs("non_existing_key"), 0, -1).get());
assertNull(client.lpop(gs("non_existing_key")).get());
assertNull(client.lpopCount(gs("non_existing_key"), 2).get());
}

@SneakyThrows
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@
import org.apache.commons.lang3.RandomStringUtils;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.Timeout;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;

@Timeout(10) // seconds
public class StandaloneClientTests {
Expand Down

0 comments on commit 17a91b2

Please sign in to comment.