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 NullPointerException
in FuseableStreamMessage
#4859
Conversation
Related issue: line#4852 Motivation: `FuseableStreamMessage.collect()` throws a NPE when only `mapError()` is applied to a normal `StreamMessage`. ``` StreamMessage.of(1, 2, 3, 4) .mapError(IllegalStateException::new) // Raises a NullPointerException .collect().join(); ``` `function` field in `FuseableStreamMessage` can be null if no `map()` is applied to `FuseableStreamMessage`. https://github.com/line/armeria/blob/871d87297e4d051241589cb1ae95641cbc83f880/core/src/main/java/com/linecorp/armeria/common/stream/FuseableStreamMessage.java#L162 The problem only happens when `collect()` method is called. `subscribe()` method already takes the case into account. Modifications: - Use the original object as is if `function` is null. Result: - You no longer see `NullPointerException` when `.mapError()` is applied to `StreamMessage` - Closes line#4852
Thanks @ikhoon for the quick fix (which LGTM)! Before we upgrade our Armeria dependency to pick up this fix, is adding a no-op |
Right. Adding |
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.
Thanks for the quick fix @ikhoon 👍 🙇 🚀
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.
Thanks! 👍
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.
Related issue: #4852
Motivation:
FuseableStreamMessage.collect()
throws aNPE
when onlymapError()
is applied to a normalStreamMessage
.The
function
field inFuseableStreamMessage
can be null if nomap()
is applied toFuseableStreamMessage
.armeria/core/src/main/java/com/linecorp/armeria/common/stream/FuseableStreamMessage.java
Line 162 in 871d872
The problem only happens when
collect()
method is called.subscribe()
method already takes the case into account.Modifications:
function
is null.Result:
NullPointerException
when.mapError()
is applied toStreamMessage
NPE
onHttpResponse
callback In gRPC client #4852