yekigoc / rosjava

Automatically exported from code.google.com/p/rosjava
0 stars 0 forks source link

Resubscribing to the same topic is broken #18

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Create a node that subscribes to topic X
2. Unsubscribe from topic X using Subscriber.shutdown()
3. Resubscribe to topic X by calling Node.createSubscriber()

What is the expected output? What do you see instead?
Expected is that the topic successfully resubscribes and data is received 
again. Instead, no data is received.

What version of the product are you using? On what operating system?
Latest version; OS independent.

Please provide any additional information below.
The reason this is happening is due to the caching of subscribers/topics. Until 
recently, Subscriber.cancel() was the method for shutting down a subscription. 
This method simply removed the message listener created during 
Node.createSubscriber(), but left the actual Subscriber/Topic class and receive 
thread running. Then, the SubscriberFactory would simply return the still 
active Subscriber/Topic and add the new listener, so that the subscription is 
complete.

Now, since Subscriber.shutdown() is called, the subscriber thread is killed, 
but the Subscriber/Topic is never removed from the TopicManager, so when 
Node.createSubscriber() is called, and subsequently SubscriberFactory is asked 
for a subscriber, the dead Subscriber/Topic is returned instead of a new one.

Original issue reported on code.google.com by ersso...@gmail.com on 1 Jul 2011 at 2:25

GoogleCodeExporter commented 9 years ago

Original comment by damonkoh...@google.com on 4 Jan 2012 at 9:59