Skip to content
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

AdvancedPublisherBuilder uses incorrect lifetime when creating AdvancedPublisher #1670

Closed
skreborn opened this issue Dec 13, 2024 · 0 comments · Fixed by #1671
Closed

AdvancedPublisherBuilder uses incorrect lifetime when creating AdvancedPublisher #1670

skreborn opened this issue Dec 13, 2024 · 0 comments · Fixed by #1671
Assignees
Labels
bug Something isn't working

Comments

@skreborn
Copy link

Describe the bug

The Resolvable implementation for AdvancedPublisherBuilder uses the wrong lifetime, as well as AdvancedPublisher::new.

Current implementation:

impl<'a> Resolvable for AdvancedPublisherBuilder<'a, '_, '_> {
    type To = ZResult<AdvancedPublisher<'a>>;
}

// ...

impl<'a> AdvancedPublisher<'a> {
    #[zenoh_macros::unstable]
    fn new(conf: AdvancedPublisherBuilder<'a, '_, '_>) -> ZResult<Self> {

Fixed implementation:

impl<'b> Resolvable for AdvancedPublisherBuilder<'_, 'b, '_> {
    type To = ZResult<AdvancedPublisher<'b>>;
}

// ...

impl<'a> AdvancedPublisher<'a> {
    #[zenoh_macros::unstable]
    fn new(conf: AdvancedPublisherBuilder<'_, 'a, '_>) -> ZResult<Self> {

The fix is based on the Resolvable implementation for the regular PublisherBuilder, which similarly uses the lifetime associated with the KeyExpr.

To reproduce

Create an AdvancedPublisher with a KeyExpr<'static>. The resulting instance won't be an AdvancedPublisher<'static>.

System info

Zenoh 1.1.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants