Skip to content

xread with block=0 doesn't block #2277

@awaizman1

Description

@awaizman1

Expected behavior

According to redis documentation when passing block=0 to xread command, the operation should block forever (until has data to read).

From the documentation:

"... I specified the new BLOCK option with a timeout of 0 milliseconds (that means to never timeout)"

In Jedis, when I pass block=0 it seems like the BLOCK param is omitted at all from the sent command thus the xread command won't block at all.

BinaryClient.java:

public void xread(final int count, final long block, final Map<byte[], byte[]> streams) {
    ...
    if(block > 0) {
        params[streamsIndex++] = Keyword.BLOCK.raw;
        params[streamsIndex++] = toByteArray(block);
    }
    ...

I also validate this behavior with the python client and redis-cli and indeed block=0 means block forever.

I guess the block argument to Jedis.xread should be optional, when provided it should be passed to redis for any value >= 0 (negative value are not allowed)

Redis / Jedis Configuration

Jedis version: 3.3.0

Redis version: 5.10

Java version: 11

Thanks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions