Skip to content

Commit d8d1ae2

Browse files
committed
Addressed PR comments
Signed-off-by: Guian Gumpac <guian.gumpac@improving.com>
1 parent 3612356 commit d8d1ae2

File tree

3 files changed

+13
-9
lines changed

3 files changed

+13
-9
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#### Changes
2-
* Java: Add test for GlideString ([#2271](https://github.com/valkey-io/valkey-glide/pull/2271))
32
* Java: Fetch server version using info command ([#2258](https://github.com/valkey-io/valkey-glide/pull/2258))
43
* Node: Added binary variant for commands which have `Record` as input or output ([#2207](https://github.com/valkey-io/valkey-glide/pull/2207))
54
* Node: Renamed `ReturnType` to `GlideReturnType` ([#2241](https://github.com/valkey-io/valkey-glide/pull/2241))
@@ -119,6 +118,7 @@
119118
* Core: Change FUNCTION STATS command to return multi node response for standalone mode ([#2117](https://github.com/valkey-io/valkey-glide/pull/2117))
120119

121120
#### Fixes
121+
* Java: Java: Fix byte conversion to GlideString bug ([#2271](https://github.com/valkey-io/valkey-glide/pull/2271))
122122
* Java: Add overloads for XADD to allow duplicate entry keys ([#1970](https://github.com/valkey-io/valkey-glide/pull/1970))
123123
* Node: Fix ZADD bug where command could not be called with only the `changed` optional parameter ([#1995](https://github.com/valkey-io/valkey-glide/pull/1995))
124124
* Java: `XRange`/`XRevRange` should return `null` instead of `GlideException` when given a negative count ([#1920](https://github.com/valkey-io/valkey-glide/pull/1920))

java/client/src/main/java/glide/utils/ArrayTransformUtils.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,7 @@ public static String[] convertMapToKeyValueStringArray(Map<String, ?> args) {
3232
}
3333

3434
/**
35-
* Converts a map of GlideString keys and values of any type in to an array of GlideStrings with
36-
* alternating keys and values.
35+
* Converts a map of GlideString keys and values to an array of GlideStrings.
3736
*
3837
* @param args Map of GlideString keys to values of GlideString.
3938
* @return Array of strings [key1, gs(value1.toString()), key2, gs(value2.toString()), ...].
@@ -65,10 +64,10 @@ public static String[] convertNestedArrayToKeyValueStringArray(String[][] args)
6564
}
6665

6766
/**
68-
* Converts a nested array of GlideString keys and values of any type in to an array of
69-
* GlideStrings with alternating keys and values.
67+
* Converts a nested array of GlideString keys and values in to an array of GlideStrings with
68+
* alternating keys and values.
7069
*
71-
* @param args Nested array of GlideString keys to values of any type to convert.
70+
* @param args Nested array of GlideString keys and values to convert.
7271
* @return Array of strings [key1, gs(value1.toString()), key2, gs(value2.toString()), ...].
7372
*/
7473
public static GlideString[] convertNestedArrayToKeyValueGlideStringArray(GlideString[][] args) {

java/integTest/src/test/java/glide/SharedCommandTests.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -996,20 +996,25 @@ public void non_UTF8_GlideString_test(BaseClient client) {
996996
String stringField = "field";
997997
Map<GlideString, GlideString> fieldValueMap = Map.of(gs(stringField), value);
998998

999-
// Non UTF-8 key and value
999+
// Testing keys and values using byte[] that cannot be converted to UTF-8 Strings.
10001000
assertEquals(OK, client.set(key, value).get());
10011001
assertEquals(value, client.get(key).get());
10021002

1003-
// Non UTF-8 field value map for a set
1003+
// Testing set values using byte[] that cannot be converted to UTF-8 Strings.
10041004
assertEquals(1, client.hset(hashKey, fieldValueMap).get());
10051005
assertDeepEquals(new GlideString[] {gs(stringField)}, client.hkeys(hashKey).get());
10061006
assertThrows(
10071007
ExecutionException.class, () -> client.hget(hashKey.toString(), stringField).get());
10081008

1009-
// Non UTF-8 set key and field value map
1009+
// Testing keys for a set using byte[] that cannot be converted to UTF-8 Strings returns bytes.
10101010
assertEquals(1, client.hset(hashNonUTF8Key, fieldValueMap).get());
10111011
assertDeepEquals(new GlideString[] {gs(stringField)}, client.hkeys(hashNonUTF8Key).get());
10121012
assertEquals(value, client.hget(hashNonUTF8Key, gs(stringField)).get());
1013+
1014+
// Converting non UTF-8 bytes result to String returns a message.
1015+
assertEquals(
1016+
"Value not convertible to string: byte[] 13",
1017+
client.hget(hashNonUTF8Key, gs(stringField)).get().toString());
10131018
}
10141019

10151020
@SneakyThrows

0 commit comments

Comments
 (0)