Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lettuce doesn't handle null response for Redis key (NullPointerException) #2596

Closed
kuznecc opened this issue Jan 17, 2024 · 0 comments
Closed
Labels
status: good-first-issue An issue that can only be worked on by brand new contributors type: bug A general bug
Milestone

Comments

@kuznecc
Copy link

kuznecc commented Jan 17, 2024

Bug Report

The problem is similar to /issues/1474 which was related to a different place in the code but has the same symptoms.

When I try to get a value from

Current Behavior

Lettuce throws a NullPointerException when I try to get a value range for a zset by a key that is absent or has a null value.
At the same moment, the 'size' request works as expected for the same keys.

Stack trace
Caused by: java.lang.NullPointerException: Cannot invoke "java.nio.ByteBuffer.remaining()" because "buffer" is null
    at io.lettuce.core.codec.ByteArrayCodec.getBytes(ByteArrayCodec.java:84)
    at io.lettuce.core.codec.ByteArrayCodec.decodeValue(ByteArrayCodec.java:64)
    at io.lettuce.core.codec.ByteArrayCodec.decodeValue(ByteArrayCodec.java:28)
    at io.lettuce.core.output.ScoredValueListOutput.set(ScoredValueListOutput.java:54)
    at io.lettuce.core.protocol.RedisStateMachine.safeSet(RedisStateMachine.java:806)
    at io.lettuce.core.protocol.RedisStateMachine.handleNull(RedisStateMachine.java:397)
    at io.lettuce.core.protocol.RedisStateMachine$State$Type.handle(RedisStateMachine.java:205)
    at io.lettuce.core.protocol.RedisStateMachine.doDecode(RedisStateMachine.java:339)
    at io.lettuce.core.protocol.RedisStateMachine.decode(RedisStateMachine.java:300)
    at io.lettuce.core.protocol.CommandHandler.decode(CommandHandler.java:840)
    at io.lettuce.core.protocol.CommandHandler.decode0(CommandHandler.java:791)
    at io.lettuce.core.protocol.CommandHandler.decode(CommandHandler.java:765)
    at io.lettuce.core.protocol.CommandHandler.decode(CommandHandler.java:657)
    at io.lettuce.core.protocol.CommandHandler.channelRead(CommandHandler.java:597)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:442)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412)
    at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1410)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:440)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420)
    at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:919)
    at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:166)
    at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:788)
    at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:724)
    at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:650)
    at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:562)
    at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:997)
    at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
    at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
    at java.lang.Thread.run(Thread.java:833) ~[?:?]

Input Code

Input Code
stringRedisTemplate.opsForZSet().rangeWithScores("KEY_WITH_NULL_VALUE_OR_ABSENT", 0, 0)

Expected behavior/code

no NPE

Environment

  • Lettuce version(s): 6.3.1.RELEASE
  • Redis version: 5.1.1

Possible Solution

Additional context

@tishun tishun added type: bug A general bug status: good-first-issue An issue that can only be worked on by brand new contributors labels Jun 28, 2024
@thachlp thachlp mentioned this issue Jul 1, 2024
4 tasks
@tishun tishun closed this as completed Jul 3, 2024
@tishun tishun added this to the 7.x milestone Jul 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: good-first-issue An issue that can only be worked on by brand new contributors type: bug A general bug
Projects
None yet
Development

No branches or pull requests

2 participants