Skip to content
Snippets Groups Projects
Commit aa381199 authored by Julian Cerruti's avatar Julian Cerruti Committed by GitHub
Browse files

Merge pull request #238 from stratomda/fix/DefaultPublisherLeak

This fixes rosjava/rosjava_core#237. Added fix to remove Publishers a…
parents a0b24683 aa09395e
No related branches found
No related tags found
No related merge requests found
......@@ -39,6 +39,8 @@ import org.ros.internal.node.service.ServiceDeclaration;
import org.ros.internal.node.service.ServiceFactory;
import org.ros.internal.node.service.ServiceIdentifier;
import org.ros.internal.node.service.ServiceManager;
import org.ros.internal.node.topic.DefaultPublisher;
import org.ros.internal.node.topic.DefaultSubscriber;
import org.ros.internal.node.topic.PublisherFactory;
import org.ros.internal.node.topic.SubscriberFactory;
import org.ros.internal.node.topic.TopicDeclaration;
......@@ -403,12 +405,7 @@ public class DefaultNode implements ConnectedNode {
// NOTE(damonkohler): We don't want to raise potentially spurious
// exceptions during shutdown that would interrupt the process. This is
// simply best effort cleanup.
for (Publisher<?> publisher : topicParticipantManager.getPublishers()) {
publisher.shutdown();
}
for (Subscriber<?> subscriber : topicParticipantManager.getSubscribers()) {
subscriber.shutdown();
}
topicParticipantManager.shutdown();
for (ServiceServer<?, ?> serviceServer : serviceManager.getServers()) {
try {
Response<Integer> response =
......
......@@ -109,6 +109,7 @@ public class DefaultPublisher<T> extends DefaultTopicParticipant implements Publ
public void shutdown(long timeout, TimeUnit unit) {
signalOnShutdown(timeout, unit);
outgoingMessageQueue.shutdown();
listeners.shutdown();
}
@Override
......
......@@ -136,6 +136,19 @@ public class TopicParticipantManager {
publisherConnections.remove(publisher, subscriberIdentifier);
}
public void shutdown(){
for(DefaultPublisher<?> publisher : publishers.values()){
publisher.shutdown();
removePublisher(publisher);
}
subscriberConnections.clear();
for(DefaultSubscriber<?> subscriber : subscribers.values()){
subscriber.shutdown();
removeSubscriber(subscriber);
}
publisherConnections.clear();
}
public Collection<DefaultSubscriber<?>> getSubscribers() {
return ImmutableList.copyOf(subscribers.values());
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment