Skip to content

Conversation

@tomharmon
Copy link
Contributor

Motivation

Without this change the inner service may panic! since the cloned service may not be the ready service as described in
the tower docs

Solution

Use std::mem::replace to swap the ready and cloned services

@tomharmon tomharmon force-pushed the fix/auth-clone-issue branch from cc5107a to 5c769b5 Compare April 24, 2025 00:48
@tomharmon tomharmon force-pushed the fix/auth-clone-issue branch from 5c769b5 to 72670ea Compare April 24, 2025 16:44
In the `AsyncRequireAuthorization` service, the cloned service could be
different than the ready service due to the complexities described here:
https://docs.rs/tower/latest/tower/trait.Service.html#be-careful-when-cloning-inner-services
so this commit fixes it by using std::mem::replace as recommended in the
documentation
@tomharmon tomharmon force-pushed the fix/auth-clone-issue branch from 72670ea to a5226e9 Compare April 24, 2025 16:45
@tomharmon tomharmon changed the title fix: use mem::replace on cloned inner service fix: use mem::swap on cloned inner service Apr 24, 2025
@jplatte jplatte merged commit 45ce10b into tower-rs:main Apr 24, 2025
11 checks passed
@jplatte
Copy link
Member

jplatte commented Apr 24, 2025

Thanks!

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.

2 participants