Skip to content

Return empty array instead of nil array for XPENDING #403

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

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions cmd_stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -1274,7 +1274,7 @@ func writeXpending(
consumer *string,
) {
if len(g.pending) == 0 || count < 0 {
c.WriteLen(-1)
c.WriteLen(0)
return
}

Expand Down Expand Up @@ -1314,7 +1314,7 @@ func writeXpending(
}
}
if len(res) == 0 {
c.WriteLen(-1)
c.WriteLen(0)
return
}
c.WriteLen(len(res))
Expand Down
12 changes: 6 additions & 6 deletions cmd_stream_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -966,7 +966,7 @@ func TestStreamXpending(t *testing.T) {
)
mustDo(t, c,
"XPENDING", "planets", "processing", "-", "+", "-99",
proto.NilList,
proto.Array(),
)

// Increase delivery count
Expand All @@ -992,11 +992,11 @@ func TestStreamXpending(t *testing.T) {

mustDo(t, c,
"XPENDING", "planets", "processing", "IDLE", "5000", "-", "+", "999",
proto.NilList,
proto.Array(),
)
mustDo(t, c,
"XPENDING", "planets", "processing", "-", "+", "999", "bob",
proto.NilList,
proto.Array(),
)
mustDo(t, c,
"XPENDING", "planets", "processing", "IDLE", "4000", "-", "+", "999", "alice",
Expand All @@ -1016,7 +1016,7 @@ func TestStreamXpending(t *testing.T) {
)
mustDo(t, c,
"XPENDING", "planets", "processing", "-", "+", "999",
proto.NilList,
proto.Array(),
)
})

Expand Down Expand Up @@ -1429,7 +1429,7 @@ func TestStreamClaim(t *testing.T) {
)
mustDo(t, c,
"XPENDING", "planets", "processing", "-", "+", "999",
proto.NilList,
proto.Array(),
)

mustDo(t, c,
Expand Down Expand Up @@ -1688,6 +1688,6 @@ func TestStreamClaim(t *testing.T) {
)
mustDo(t, c,
"XPENDING", "planets", "processing", "-", "+", "999",
proto.NilList,
proto.Array(),
)
}