Change accessor of filterstate to a const shared_ptr ref#9845
Change accessor of filterstate to a const shared_ptr ref#9845mattklein123 merged 17 commits intoenvoyproxy:masterfrom
Conversation
afae9d9 to
a78d3d8
Compare
|
/cc @mandarjog |
mattklein123
left a comment
There was a problem hiding this comment.
At a high level LGTM but some small comments and also needs tests. Thanks!
/wait
There was a problem hiding this comment.
Can you just make the reference method above return the shared_ptr? You can return a const reference to the shared_ptr which should make this just as efficient in the common case. Then we don't need this new method.
There was a problem hiding this comment.
@mattklein123 : Won't that mean changing a lot more files because we would be changing a commonly used signature?
I agree it would be better going forward...
There was a problem hiding this comment.
I doubt there are that many call-sites. I would just fix them.
There was a problem hiding this comment.
sure.. updating it then..
There was a problem hiding this comment.
define FilterStateSharedPtr (i.e. using FilterStateSharedPtr = std::shared_ptr<FilterState>;) in filter_state.h and use it everywhere possible.
There was a problem hiding this comment.
const FilterStateSharedPtr filterState() const override { return filter_state_;} is not correct, as you are returning a const shared_ptr by value. Just leave the const version as it was, or change it to return a shared_ptr to a const object.
also, it's better to return shared_ptr by value as compared to reference, so as to avoid lifecycle issues
We do this in many places to avoid the copy/inc where necessary. Please return by const ref. Thanks!
There was a problem hiding this comment.
Thanks for the feedback. PTAL at the PR again!
(I have to say, I learnt about constness with respect to shared_ptr's)
There was a problem hiding this comment.
Return const ref shared_ptr
There was a problem hiding this comment.
not needed here and elsewhere.
4cb26f3 to
66b7d9f
Compare
mattklein123
left a comment
There was a problem hiding this comment.
Please split this into two changes. The first can just be the shared_ptr conversion with no other upstream changes, and then we can do the upstream change and make sure we have sufficient testing for that. Thank you!
/wait
cfca724 to
559cb1c
Compare
51a4568 to
a2e15c9
Compare
mattklein123
left a comment
There was a problem hiding this comment.
Generally LGTM with small comments, thank you.
/wait
source/common/router/router.cc
Outdated
There was a problem hiding this comment.
In many places in this change you have added a nullptr check where it did not exist before. This pointer should never be null, so you can remove this check here and elsewhere.
There was a problem hiding this comment.
I just feel better to have null protection for ptrs :) so that it doesn't bite later on...
removing the extra protection I added
There was a problem hiding this comment.
nit: '{}' not needed here and elsewhere.
Signed-off-by: gargnupur <gargnupur@google.com>
Signed-off-by: gargnupur <gargnupur@google.com>
Signed-off-by: gargnupur <gargnupur@google.com>
Signed-off-by: gargnupur <gargnupur@google.com>
Signed-off-by: gargnupur <gargnupur@google.com>
Signed-off-by: gargnupur <gargnupur@google.com>
Signed-off-by: gargnupur <gargnupur@google.com>
Signed-off-by: gargnupur <gargnupur@google.com>
Signed-off-by: gargnupur <gargnupur@google.com>
Signed-off-by: gargnupur <gargnupur@google.com>
…impl.cc Signed-off-by: gargnupur <gargnupur@google.com>
Signed-off-by: gargnupur <gargnupur@google.com>
645196a to
6acd1cf
Compare
Ref: envoyproxy/envoy-wasm#291
Description: This is part one of the change to add an option to support looking up filterstate from upstream filters. This change just changes the non-const accessor of filterstate to a const shared_ptr ref of non-const filterstate object.
Risk Level: Low
Testing:
Docs Changes:
Release Notes:
[Optional Fixes #Issue]
[Optional Deprecated:]