[fix][authorization] Fix the return value of canConsumeAsync#19412
[fix][authorization] Fix the return value of canConsumeAsync#19412nodece merged 2 commits intoapache:masterfrom
Conversation
Signed-off-by: Zixuan Liu <nodeces@gmail.com>
| log.warn("Client with Role - {} failed to get permissions for topic - {}. {}", role, topicName, | ||
| ex.getMessage()); | ||
| return null; | ||
| throw FutureUtil.wrapToCompletionException(ex); |
There was a problem hiding this comment.
Is the logging just extra noise if the exception gets rethrown? Could we remove the .exceptionally completely? My assumption is that rethrowing could lead to the exception being logged more than 1 time.
I guess return null; is wrong and could be return false; if the desire is to just log and continue by returning false. The original code (before this PR) will fail with NullPointerException since the expected return value is Boolean.
There was a problem hiding this comment.
We already log the "error" multiple times. We log it in this class as a warning. We also have these logs for handling the result of this method:
After this change, we could have 3 lines and a stack trace. I think that is too many. I would prefer to simplify the code path and only log a single failure/error/rejection once.
michaeljmarshall
left a comment
There was a problem hiding this comment.
My preference is to remove the exceptionally block all together and to make sure that pulsar logs the errors accordingly. Since this AuthorizationProvider is pluggable, it simplifies the flow if implementations can rely on pulsar to log appropriately in my opinion.
Let me know what you think @nodece. Thanks!
| log.warn("Client with Role - {} failed to get permissions for topic - {}. {}", role, topicName, | ||
| ex.getMessage()); | ||
| return null; | ||
| throw FutureUtil.wrapToCompletionException(ex); |
There was a problem hiding this comment.
We already log the "error" multiple times. We log it in this class as a warning. We also have these logs for handling the result of this method:
After this change, we could have 3 lines and a stack trace. I think that is too many. I would prefer to simplify the code path and only log a single failure/error/rejection once.
|
I want to remove all |
michaeljmarshall
left a comment
There was a problem hiding this comment.
LGTM, thanks @nodece!
|
/pulsarbot rerun-failure-checks |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #19412 +/- ##
============================================
- Coverage 32.36% 26.48% -5.88%
- Complexity 6355 6369 +14
============================================
Files 1648 1581 -67
Lines 123990 121828 -2162
Branches 13523 13304 -219
============================================
- Hits 40129 32271 -7858
- Misses 77958 84925 +6967
+ Partials 5903 4632 -1271
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
Signed-off-by: Zixuan Liu <nodeces@gmail.com>
Signed-off-by: Zixuan Liu <nodeces@gmail.com> (cherry picked from commit 016e7f0)
Motivation
When an exception occurs in the
canConsumeAsyncmethod, we should throw that.Documentation
docdoc-requireddoc-not-neededdoc-complete