Skip to content
This repository was archived by the owner on Aug 11, 2023. It is now read-only.
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

Description

@chadrockey

Original author: psi...@gmail.com (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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions