Skip to content

http: prefer to return reference rather than shared pointer for virtualhost()#44048

Merged
wbpcode merged 3 commits into
envoyproxy:mainfrom
wbpcode:dev-virtual-host-new-style
Mar 24, 2026
Merged

http: prefer to return reference rather than shared pointer for virtualhost()#44048
wbpcode merged 3 commits into
envoyproxy:mainfrom
wbpcode:dev-virtual-host-new-style

Conversation

@wbpcode
Copy link
Copy Markdown
Member

@wbpcode wbpcode commented Mar 20, 2026

Commit Message: http: prefer to return reference rather than shared pointer for virtualhost()
Additional Description:

See #44025 for our new style.

Risk Level: n/a.
Testing: n/a.
Docs Changes: n/a.
Release Notes: n/a.
Platform Specific Features: n/a.

…alHost()

Signed-off-by: wbpcode/wangbaiping <wbphub@gmail.com>
@wbpcode wbpcode requested a review from mattklein123 as a code owner March 20, 2026 15:41
@wbpcode wbpcode marked this pull request as draft March 20, 2026 16:13
Signed-off-by: wbpcode/wangbaiping <wbphub@gmail.com>
@wbpcode wbpcode marked this pull request as ready for review March 21, 2026 07:43
Copy link
Copy Markdown
Contributor

@ravenblackx ravenblackx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably would be worth having a relnote about all of these changes, in one of these PRs (or on its own afterwards), so that anyone who has custom extensions has a heads-up about needing to replace -> with . a lot (or to give the function +SharedPtr for a rare case).

Comment thread envoy/router/router.h
Comment thread source/common/router/config_impl.h Outdated
return vhost_copy_;
}
const VirtualHost& virtualHost() const override { return *vhost_; }
VirtualHostConstSharedPtr virtualHostSharedPtr() const override { return vhost_copy_; }
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
VirtualHostConstSharedPtr virtualHostSharedPtr() const override { return vhost_copy_; }
VirtualHostConstSharedPtr virtualHostSharedPtr() const override { return vhost_; }

And delete vhost_copy_ from the class and the constructor, it's no longer necessary because of not returning a reference to a shared_ptr.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. Thanks.

Signed-off-by: wbpcode/wangbaiping <wbphub@gmail.com>
@wbpcode
Copy link
Copy Markdown
Member Author

wbpcode commented Mar 23, 2026

Probably would be worth having a relnote about all of these changes, in one of these PRs (or on its own afterwards), so that anyone who has custom extensions has a heads-up about needing to replace -> with . a lot (or to give the function +SharedPtr for a rare case).

iguess the modern IDE should will give a clear suggestion once the developers encounter a compilation problem.

But i won't against the note if you prefer it. Where will you suggest to add the note? Change log? Or a message at envoy-dev channel?

@wbpcode
Copy link
Copy Markdown
Member Author

wbpcode commented Mar 23, 2026

/retest

@ravenblackx
Copy link
Copy Markdown
Contributor

iguess the modern IDE should will give a clear suggestion once the developers encounter a compilation problem.

But i won't against the note if you prefer it. Where will you suggest to add the note? Change log? Or a message at envoy-dev channel?

I know I, as a person who maintains a bunch of custom filters, would hear about it from the compilation problem more than from the changelog, but I might look at the changelog to see why it changed - and a note there would be good to make me think about whether I want SharedPtr or OptRef option, vs. if I just got the compiler complaint I would probably just pick one and do it globally without really thinking about which option makes sense.

(Probably in the minor_behavior_change section because it won't impact most users.)

@wbpcode wbpcode merged commit 11299f2 into envoyproxy:main Mar 24, 2026
29 checks passed
@wbpcode wbpcode deleted the dev-virtual-host-new-style branch March 24, 2026 02:25
fishcakez pushed a commit to fishcakez/envoy that referenced this pull request Mar 25, 2026
…alhost() (envoyproxy#44048)

Commit Message: http: prefer to return reference rather than shared
pointer for virtualhost()
Additional Description:

See envoyproxy#44025 for our new style.

Risk Level: n/a.
Testing: n/a.
Docs Changes: n/a.
Release Notes: n/a.
Platform Specific Features: n/a.

---------

Signed-off-by: wbpcode/wangbaiping <wbphub@gmail.com>
TAOXUY pushed a commit to TAOXUY/envoy that referenced this pull request Apr 1, 2026
…alhost() (envoyproxy#44048)

Commit Message: http: prefer to return reference rather than shared
pointer for virtualhost()
Additional Description:

See envoyproxy#44025 for our new style.

Risk Level: n/a.
Testing: n/a.
Docs Changes: n/a.
Release Notes: n/a.
Platform Specific Features: n/a.

---------

Signed-off-by: wbpcode/wangbaiping <wbphub@gmail.com>
Signed-off-by: Xuyang Tao <taoxuy@google.com>
citrus7 pushed a commit to citrus7/envoy that referenced this pull request Apr 1, 2026
…alhost() (envoyproxy#44048)

Commit Message: http: prefer to return reference rather than shared
pointer for virtualhost()
Additional Description:

See envoyproxy#44025 for our new style.

Risk Level: n/a.
Testing: n/a.
Docs Changes: n/a.
Release Notes: n/a.
Platform Specific Features: n/a.

---------

Signed-off-by: wbpcode/wangbaiping <wbphub@gmail.com>
Signed-off-by: Jonathan Wu <jtwu@google.com>
nshipilov pushed a commit to nshipilov/envoy that referenced this pull request Apr 13, 2026
…alhost() (envoyproxy#44048)

Commit Message: http: prefer to return reference rather than shared
pointer for virtualhost()
Additional Description:

See envoyproxy#44025 for our new style.

Risk Level: n/a.
Testing: n/a.
Docs Changes: n/a.
Release Notes: n/a.
Platform Specific Features: n/a.

---------

Signed-off-by: wbpcode/wangbaiping <wbphub@gmail.com>
Signed-off-by: Nick Shipilov <nick.shipilov.n@gmail.com>
krinkinmu pushed a commit to grnmeira/envoy that referenced this pull request Apr 20, 2026
…alhost() (envoyproxy#44048)

Commit Message: http: prefer to return reference rather than shared
pointer for virtualhost()
Additional Description:

See envoyproxy#44025 for our new style.

Risk Level: n/a.
Testing: n/a.
Docs Changes: n/a.
Release Notes: n/a.
Platform Specific Features: n/a.

---------

Signed-off-by: wbpcode/wangbaiping <wbphub@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants