Skip to content
This repository was archived by the owner on Aug 11, 2023. It is now read-only.

ServiceServer shutdown during Node shutdown causes null pointer exception #27

Closed
chadrockey opened this issue Jan 3, 2013 · 0 comments

Comments

@chadrockey
Copy link
Contributor

Original author: [email protected] (August 18, 2011 11:44:00)

What steps will reproduce the problem?

  1. Create a node
  2. Use node.newServiceServer to register a ServiceServer
  3. Call node.shutdown()

What is the expected output? What do you see instead?

The node should close down cleanly, or at least catch all exceptions. Instead, a NullPointerException is thrown:

org.ros.exception.RosRuntimeException: java.lang.NullPointerException
at org.ros.address.AdvertiseAddress.toUri(AdvertiseAddress.java:109)
at org.ros.internal.node.service.DefaultServiceServer.getUri(DefaultServiceServer.java:86)
at org.ros.internal.node.client.MasterClient.unregisterService(MasterClient.java:84)
at org.ros.internal.node.DefaultNode.shutdown(DefaultNode.java:364)
at edu.cmu.ri.crw.ros.RosVehicleServer.shutdown(RosVehicleServer.java:406)
at edu.cmu.ri.crw.test.TestRosServer.main(TestRosServer.java:90)

What version of the product are you using? On what operating system?

Latest version from repo.

Please provide any additional information below.

This bug is caused by the ordering of commands in DefaultNode.shutdown().

Specifically, slaveServer.shutdown() is called before masterClient.unregisterService(slaveServer.toSlaveIdentifier(), serviceServer).

slaveServer contains the Callable<Integer> holding the port number of the URI that the ServiceServer is using. After slaveServer is shutdown, this Callable is no longer valid, so the ServiceServer fails when it calls getURI() to get the URI to unregister from the ROS master.

Proposed solution:

Move slaveServer.shutdown() and registrar.shutdown() to the end of DefaultNode.shutdown() -- it seems likely that other unregistration processes will depend on them. Patch is attached.

Original issue: http://code.google.com/p/rosjava/issues/detail?id=27

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant