Skip to content

Unsubscribe from topic safely #105

@jacobperron

Description

@jacobperron

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.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions