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.

1

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.

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

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.