0

We are using Lettuce java client to connect to AWS Elasticache (Valkey engine, Serverless, version 8.0) from Java springboot application (JDK 17 & springboot version 3.2.5)

Below is the method where I am trying to read multiple keys from elasticache using jsonMGet().

public List<JsonValue> readMultipleKeys(List<String> keys) {
 RedisAsyncCommands<String, String> async = null;
 try {
 async = redisCacheClient.connect().async();
 return async.jsonMGet(JsonPath.ROOT_PATH, keys.toArray(new String[0])).get();
 } catch (Exception e) {
 log.error("Exception while reading multiple keys from Cache: " + e.getMessage());
 return null;
 }
 }

Everything works perfectly fine as long as all the keys from the input list are present in Cache. But if any key (lets say 1 out of 100 input keys) doesn't exist in cache, it is throwing below error and not returning any other values.

Exception while reading from Cache: java.lang.NullPointerException: Cannot invoke "java.nio.ByteBuffer.remaining()" because "bytes" is null

I want the method to return all the keys that are PRESENT in cache and ignore the keys that doesn't exist.

desertnaut
60.7k32 gold badges155 silver badges183 bronze badges
asked Apr 3 at 12:20
1
  • Which version of the Lettuce driver are you using? A similar issue was addressed with this issue in the 6.5.5 release, see github.com/redis/lettuce/issues/3196 Commented Apr 4 at 6:57

1 Answer 1

1

EDIT: This seems to be addressed in Lettuce 6.5.5 and later

A NullPointerException is almost certainly a bug.

I've taken the liberty to create one in the GitHub tracker for you: https://github.com/redis/lettuce/issues/3241

I suggest we continue the conversation there.

answered Apr 3 at 14:12
Sign up to request clarification or add additional context in comments.

1 Comment

Thank you. Have upgraded to 6.5.5 and issue got resolved!

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.