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

NullPointerException during node shutdown #279

Open
qswawrq opened this issue May 21, 2018 · 5 comments
Open

NullPointerException during node shutdown #279

qswawrq opened this issue May 21, 2018 · 5 comments
Labels

Comments

@qswawrq
Copy link

qswawrq commented May 21, 2018

This is a question about #27. I saw the same exception during some normal shutdowns. Do we have a fix for that? Or we should simply ignore it and avoid catch this type of Exception during shutdown.

org.ros.exception.RosRuntimeException: java.lang.NullPointerException
	at org.ros.address.AdvertiseAddress.toString(AdvertiseAddress.java:123)
	at java.lang.String.valueOf(String.java:2994)
	at java.lang.StringBuilder.append(StringBuilder.java:131)
	at org.ros.address.AdvertiseAddress.toUri(AdvertiseAddress.java:109)
	at org.ros.internal.node.service.DefaultServiceServer.getUri(DefaultServiceServer.java:117)
	at org.ros.internal.node.client.MasterClient.unregisterService(MasterClient.java:91)
	at org.ros.internal.node.DefaultNode.shutdown(DefaultNode.java:424)
        ...
        at org.ros.internal.transport.queue.MessageDispatcher$1.run(MessageDispatcher.java:125)
	at org.ros.internal.transport.queue.MessageDispatcher$1.run(MessageDispatcher.java:122)
	at org.ros.concurrent.EventDispatcher.loop(EventDispatcher.java:43)
	at org.ros.concurrent.CancellableLoop.run(CancellableLoop.java:56)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.NullPointerException
	at org.ros.internal.transport.tcp.TcpRosServer$1.call(TcpRosServer.java:91)
	at org.ros.internal.transport.tcp.TcpRosServer$1.call(TcpRosServer.java:88)
	at org.ros.address.AdvertiseAddress.toString(AdvertiseAddress.java:121)
	... 17 more
@jubeira
Copy link

jubeira commented May 21, 2018

Hi @qswawrq, thanks for reporting this. It seems that this issue was closed long ago, but there's no reference to the fix.
Does this happen always to you, or in some particular situation? Do you have some simple code sample to reproduce? Does it have any functional consequences in your code?

@qswawrq
Copy link
Author

qswawrq commented May 21, 2018

Thanks for reply so quickly. I think #27 provides a good way to reproduce it. Based on my understanding, SlaveServer shutdown will cause its TcpRosServer's outgoingChannel to be null. In that case, calling unregisterService in the for loop will trigger a NPE in advertiseAddress.toUri(), because advertiseAddress's portCallable require a non-null outgoingChannel. It is not clear to me why it is not happened all the time. The only functional consequences I can think of are some residual rosjava processes after shutdown.

@jubeira jubeira added the bug label May 22, 2018
@jubeira
Copy link

jubeira commented May 22, 2018

Alright, thanks for the info. I've been kinda short on time lately, but I will see what I can do.

If you have a proposed fix for this, please feel free to open a PR; I will review it ASAP if you do.

@qswawrq
Copy link
Author

qswawrq commented May 22, 2018

Sounds good. Will do.

@qswawrq
Copy link
Author

qswawrq commented May 22, 2018

I just realized that it might not be a simple fix. Because my fix is to revert #242, which seems to cause other issues.
Note: I just confirm it only happens in normal shutdown. It will not be triggered when you exit by Ctrl+C.

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

No branches or pull requests

2 participants