Skip to content

Fix encoding - #23

Open
Dgramada wants to merge 3 commits into
mainfrom
fix-encoding
Open

Fix encoding#23
Dgramada wants to merge 3 commits into
mainfrom
fix-encoding

Conversation

@Dgramada

@Dgramada Dgramada commented Aug 28, 2026

Copy link
Copy Markdown
Collaborator

Fully refactored encoding/decoding. Now Lettuce integration supports generic types instead of having hard coded Strings.

  • Fully removed QuarkusRedisCodec
  • Replaced StatefulRedisConnection<String, String> with StatefulRedisConnection<byte[], byte[]>
  • Refactored Key, Value, Hash, List, Set, Sorted Set command groups to encode/decode values using the Quarkus Marshaller class so that any type works instead of only String
  • Refactored testing to use POJOs instead of plain String
  • Adapted transactional tests to inherit CommandsTestBase
  • Simplified backend selection logic to use @WithDefault as per Quarkus conventions
  • Removed sensitive connection information logging in LettuceRecorder

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));

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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");

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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");

@vchomakov vchomakov Sep 4, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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");

@vchomakov vchomakov Sep 4, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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");

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same - missing doesNotContainNull; a null member queries the score of "".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants