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

jsonArrpop fails with null return value #3196

Closed
rigazilla opened this issue Feb 24, 2025 · 0 comments · Fixed by #3206
Closed

jsonArrpop fails with null return value #3196

rigazilla opened this issue Feb 24, 2025 · 0 comments · Fixed by #3206
Labels
status: mre-available Minimal Reproducible Example is available type: bug A general bug
Milestone

Comments

@rigazilla
Copy link

Bug Report

Current Behavior

jsonArrpop fails when popping from an empty array

Stack trace
{"name":"testStarted","attributes":{"name":"org.infinispan.server.resp.JsonCommandsTest#testJSONARRPOPRedis\\[authz\\\u003dfalse\\]()"}}{"name":"testFailed","attributes":{"name":"org.infinispan.server.resp.JsonCommandsTest#testJSONARRPOPRedis\\[authz\\\u003dfalse\\]()","message":"Cannot invoke "java.nio.ByteBuffer.remaining()" because "bytes" is null","trace":"java.lang.NullPointerException: Cannot invoke "java.nio.ByteBuffer.remaining()" because "bytes" is null
        at io.lettuce.core.output.JsonValueListOutput.set(JsonValueListOutput.java:42)
        at io.lettuce.core.protocol.RedisStateMachine.safeSet(RedisStateMachine.java:814)
        at io.lettuce.core.protocol.RedisStateMachine.handleNull(RedisStateMachine.java:421)
        at io.lettuce.core.protocol.RedisStateMachine$State$Type.handle(RedisStateMachine.java:210)
        at io.lettuce.core.protocol.RedisStateMachine.doDecode(RedisStateMachine.java:363)
        at io.lettuce.core.protocol.RedisStateMachine.decode(RedisStateMachine.java:324)
        at io.lettuce.core.protocol.CommandHandler.decode(CommandHandler.java:857)
        at io.lettuce.core.protocol.CommandHandler.decode0(CommandHandler.java:808)
        at io.lettuce.core.protocol.CommandHandler.decode(CommandHandler.java:782)
        at io.lettuce.core.protocol.CommandHandler.decode(CommandHandler.java:674)
        at io.lettuce.core.protocol.CommandHandler.channelRead(CommandHandler.java:614)
        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:1407)
        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:918)
        at io.netty.channel.epoll.AbstractEpollStreamChannel$EpollStreamUnsafe.epollInReady(AbstractEpollStreamChannel.java:799)
        at io.netty.channel.epoll.EpollEventLoop.processReady(EpollEventLoop.java:501)
        at io.netty.channel.epoll.EpollEventLoop.run(EpollEventLoop.java:399)
        at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:994)
        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)
","duration":"73"}}

Input Code

Input Code
   @Test
   public void testJSONARRPOPRedis() {
      RedisCommands<String,String> redis = RedisClient.create("redis://localhost:6379").connect().sync();
      JsonPath jp = new JsonPath("$");
      JsonValue jv = defaultJsonParser.createJsonValue("""
               ["one"]
            """);
      String key = k();
      redis.jsonSet(key, jp, jv);
      List<JsonValue> result = redis.jsonArrpop(key);
      assertThat(result.toString()).isEqualTo("[\"one\"]");
      result = redis.jsonArrpop(key, jp, 0);
      assertThat(result.get(0).isNull()).isTrue();
   }

Expected behavior/code

as per documentation popping from an empt array should return null (JsonValue null node?)

Environment

  • Lettuce version(s): 6.5.4.RELEASE
  • Redis version: [e.g. 4.0.9]
    127.0.0.1:6379> info

Server

redis_version:7.4.2

Possible Solution

Additional context

@tishun tishun added the type: bug A general bug label Feb 24, 2025
@tishun tishun added this to the 6.5.5.RELEASE milestone Feb 24, 2025
@tishun tishun added status: mre-available Minimal Reproducible Example is available status: waiting-for-triage labels Feb 28, 2025
@tishun tishun closed this as completed Mar 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: mre-available Minimal Reproducible Example is available type: bug A general bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants