-
Notifications
You must be signed in to change notification settings - Fork 1k
Closed
Labels
status: mre-availableMinimal Reproducible Example is availableMinimal Reproducible Example is availabletype: bugA general bugA general bug
Milestone
Description
Bug Report
Current Behavior
I'm consistently seeing the following exception when calling hrandfieldWithvalues when there is only a single result returned. If multiple results are returned, the call succeeds.
Stack trace
java.lang.UnsupportedOperationException
at java.base/java.util.AbstractList.add(AbstractList.java:153)
at java.base/java.util.AbstractList.add(AbstractList.java:111)
at io.lettuce.core.output.ListSubscriber.onNext(ListSubscriber.java:49)
at io.lettuce.core.output.KeyValueListOutput.set(KeyValueListOutput.java:76)
at io.lettuce.core.protocol.RedisStateMachine.safeSet(RedisStateMachine.java:809)
at io.lettuce.core.protocol.RedisStateMachine.handleBytes(RedisStateMachine.java:596)
at io.lettuce.core.protocol.RedisStateMachine$State$Type.handle(RedisStateMachine.java:206)
at io.lettuce.core.protocol.RedisStateMachine.doDecode(RedisStateMachine.java:358)
at io.lettuce.core.protocol.RedisStateMachine.decode(RedisStateMachine.java:319)
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:1357)
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:868)
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.base/java.lang.Thread.run(Thread.java:840)
Input Code
Input Code
String key = "myKey";
redisClusterCommands.hset(key, "field1", "value1");
redisClusterCommands.hset(key, "field2", "value2");
//Collection<KeyValue<String, String>> values1 = redisClusterCommands.hrandfieldWithvalues(key, 2); //works fine!
Collection<KeyValue<String, String>> values2 = redisClusterCommands.hrandfieldWithvalues(key, 1); //throws exception
Expected behavior/code
no exception :)
Environment
- Lettuce version(s): 6.3.2.RELEASE
- Redis version: 7.4.2
Possible Solution
Additional context
Looks similar to #711 although that bug report indicates they ran into the error during an mget call.
I believe the bug is here in the multi method:
https://github.com/redis/lettuce/blob/main/src/main/java/io/lettuce/core/output/KeyValueListOutput.java#L77
If the count argument is one, and keys is null, the output field ends up as an immutable empty list and the UnsupportedOperationException is thrown when the code attempts to add an element to the list.
Metadata
Metadata
Assignees
Labels
status: mre-availableMinimal Reproducible Example is availableMinimal Reproducible Example is availabletype: bugA general bugA general bug