Currently, there is no safe way to unsubscribe from a topic. If the user calls dispose() on a Subscription, then it will destroy the native subscription (effectively unsubscribing), but the Node is not aware of the subscriptions disposal. E.g. getSubscriptions will return disposed subscriptions that may be accessed by executors leading an exception:
org.ros2.rcljava.exceptions.RCLException: Failed to add subscription to wait set
I think we need a way to safely remove Subscription (and Publisher) objects from a node. Whether that is through the existing Disposable interface or API added to the node (e.g. removeSubscription).
Implementation considerations
I think having the node detect when a subscription has been disposed (perhaps using WeakReference) would be nice as I don't think it would require additional API.
Currently, there is no safe way to unsubscribe from a topic. If the user calls
dispose()on aSubscription, then it will destroy the native subscription (effectively unsubscribing), but theNodeis not aware of the subscriptions disposal. E.g. getSubscriptions will return disposed subscriptions that may be accessed by executors leading an exception:I think we need a way to safely remove
Subscription(andPublisher) objects from a node. Whether that is through the existingDisposableinterface or API added to the node (e.g.removeSubscription).Implementation considerations
I think having the node detect when a subscription has been disposed (perhaps using WeakReference) would be nice as I don't think it would require additional API.