-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
Fix NPE in empty XPENDING summary #3792
Conversation
When there are no pending messages in a stream, the summary response to XPENDING contains nulls, except the first position which is 0 (the total number of pending message). Return early from the builder, in this case, to avoid NPE.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you have the test where you got NPE? Could you add that?
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #3792 +/- ##
============================================
- Coverage 79.50% 79.45% -0.05%
Complexity 5695 5695
============================================
Files 301 301
Lines 15274 15276 +2
Branches 1190 1191 +1
============================================
- Hits 12143 12138 -5
- Misses 2554 2559 +5
- Partials 577 579 +2 ☔ View full report in Codecov by Sentry. |
I have it in a big PR only with unit tests. It would be some effort to retrofit it. Would it be ok to merge this separately, and the test later? |
@@ -1813,6 +1813,11 @@ public StreamPendingSummary build(Object data) { | |||
|
|||
List<Object> objectList = (List<Object>) data; | |||
long total = BuilderFactory.LONG.build(objectList.get(0)); | |||
|
|||
if (total == 0) { | |||
return new StreamPendingSummary(total, null, null, null); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We just don't return null on our own.
We return null or whatever only after reading it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Check #3793
Fixed more properly in 7393. |
When there are no pending messages in a stream, the summary response to XPENDING contains nulls, except the first position which is 0 (the total number of pending message). Return early from the builder, in this case, to avoid NPE.