Fix encoding - #23
Conversation
Signed-off-by: yordantsintsov <yordan.tsintsov@gmail.com>
Signed-off-by: yordantsintsov <yordan.tsintsov@gmail.com>
| for (Map.Entry<A, B> e : map.entrySet()) { | ||
| byte[] value = marshaller.encode(e.getValue()); | ||
| encoded.put(marshaller.encode(nonNull(e.getKey(), "map key")), | ||
| value != null ? value : "null".getBytes(StandardCharsets.UTF_8)); |
There was a problem hiding this comment.
The null -> "null" fallback matches Vert.x only for the HMSET command. For others (MSET/HSET) Vert.x BE fails the command. Here we silently store "null". Let's reject null values and only fall back for HMSET (which is deprecated).
| final Supplier<RedisFuture<Long>> _sadd(K key, V... values) { | ||
| nonNull(key, "key"); | ||
| // `members` is the name the Vert.x backend validates under, see the class Javadoc. | ||
| notNullOrEmpty(values, "members"); |
There was a problem hiding this comment.
Missing doesNotContainNull here. A null element is encoded as an empty buffer, so sadd(key, "a", null) inserts ""
| @SafeVarargs | ||
| final Supplier<RedisFuture<List<Boolean>>> _smismember(K key, V... members) { | ||
| nonNull(key, "key"); | ||
| notNullOrEmpty(members, "members"); |
There was a problem hiding this comment.
Same here - missing doesNotContainNull; smismember(key, "a", null) checks membership of "".
| @SafeVarargs | ||
| final Supplier<RedisFuture<Long>> _sinterstore(K destination, K... keys) { | ||
| nonNull(destination, "destination"); | ||
| notNullOrEmpty(keys, "keys"); |
There was a problem hiding this comment.
Same for keys - _sdiffstore/_sunionstore have doesNotContainNull(keys, "keys"), this one doesn't.
| @SafeVarargs | ||
| final Supplier<RedisFuture<List<Double>>> _zmscore(K key, V... values) { | ||
| nonNull(key, "key"); | ||
| notNullOrEmpty(values, "values"); |
There was a problem hiding this comment.
Same - missing doesNotContainNull; a null member queries the score of "".
Fully refactored encoding/decoding. Now Lettuce integration supports generic types instead of having hard coded Strings.
QuarkusRedisCodecStatefulRedisConnection<String, String>withStatefulRedisConnection<byte[], byte[]>Marshallerclass so that any type works instead of only StringCommandsTestBase@WithDefaultas per Quarkus conventionsLettuceRecorder