Closed jjj-vtm closed 3 months ago
Thanks for pointing this out! You're completely right :)
@PLeVasseur Please assign this to me
@pranavishere2 -- you mentioned yesterday some refactoring done in this area fixed this issue.
Could you update here with info on how it was solved?
Perhaps you could also write a test to prove this out.
Prior to the update in the main branch, the following code was leading to a dead listener object even when registerListener failed:
Following the refactoring in the main branch, this issue has been resolved by introducing an exception when the registerListener call fails. The updated implementation ensures that if the listener cannot be registered, an error is thrown to prevent the dead listener object. Below is the code snippet:
Also the listener is added in the map at the end of the function only when all preconditions are satisfied: https://github.com/eclipse-uprotocol/up-streamer-rust/blob/541160edb5c4567cdcfa6c489dd7656c905fa678/up-streamer/src/ustreamer.rs#L302C1-L307C38
This makes sure there will not be any dead listner when registerListener API fails.
@pranavishere2 -- please use code tags to put the code in and give references to the main branch which files / lines, i.e. use links.
@pranavishere2 -- please use code tags to put the code in and give references to the main branch which files / lines, i.e. use links.
Done
Thanks @pranavishere2 -- closing as completed by #20
If register_listener fails there is only a log message
https://github.com/eclipse-uprotocol/up-streamer-rust/blob/d4ab17fbc745705290e29e5251fa8e9fcbffe943/up-streamer/src/ustreamer.rs#L153C1-L173
but the constructed tuple is added to forwarding_listeners and set to active. This basically leaves a "dead" listener in the HashMap.