You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Time-to-time my tests were failing with the following stacktrace:
32 INFO [CoapEndpoint]: Starting endpoint at 0.0.0.0/0.0.0.0:0 - (org.eclipse.californium.core.network.CoapEndpoint.java:115) start() in thread Thread-6 at (2016-06-15 19:46:40)
at org.eclipse.californium.core.network.CoapEndpoint.runInProtocolStage(CoapEndpoint.java:692)
at org.eclipse.californium.core.network.CoapEndpoint.sendRequest(CoapEndpoint.java:390)
at org.eclipse.californium.core.CoapClient.send(CoapClient.java:897)
at org.eclipse.californium.core.CoapClient.send(CoapClient.java:879)
at org.eclipse.californium.core.CoapClient.asynchronous(CoapClient.java:742)
at org.eclipse.californium.core.CoapClient.advanced(CoapClient.java:663)
at <SKIPPED>
at java.lang.Thread.run(Thread.java:745)
32 INFO [EndpointManager]: Created implicit default endpoint 0.0.0.0/0.0.0.0:39102 - (org.eclipse.californium.core.network.EndpointManager.java:98) createDefaultEndpoint() in thread Thread-6 at (2016-06-15 19:46:40)
The code made concurrent asynchronous requests via CoapClient using default endpoint (no endpoint was specified).
So, when two threads invoked CoapClient#advanced(CoapHandler, Request) they called EndpointManager#getDefaultEndpoint somewhere down in the hierarchy.
getDefaultEndpoint invoked synchronized createDefaultEndpoint but as long as getDefaultEndpoint is not synchronized, second thread got default_endpoint != null and proceeded. But the default_endpoint was not started yet so CoapEndpoint#executor was not filled.
It is actually a cause of that NPE.
createDefaultSecureEndpoint is not synchronized too.
I am preparing a PR (actually just adding two 'synchronized') now.
But I am not sure it is possible to make a unit test for this case.
The text was updated successfully, but these errors were encountered:
Time-to-time my tests were failing with the following stacktrace:
The code made concurrent asynchronous requests via CoapClient using default endpoint (no endpoint was specified).
After some debug, I discovered a race condition.
EndpointManager:
CoapEndpoint:
So, when two threads invoked CoapClient#advanced(CoapHandler, Request) they called EndpointManager#getDefaultEndpoint somewhere down in the hierarchy.
getDefaultEndpoint invoked synchronized createDefaultEndpoint but as long as getDefaultEndpoint is not synchronized, second thread got default_endpoint != null and proceeded. But the default_endpoint was not started yet so CoapEndpoint#executor was not filled.
It is actually a cause of that NPE.
createDefaultSecureEndpoint is not synchronized too.
I am preparing a PR (actually just adding two 'synchronized') now.
But I am not sure it is possible to make a unit test for this case.
The text was updated successfully, but these errors were encountered: