Leshan client doesn't send response to bootstrap finish message in all cases (race condition)
See original GitHub issueThere’s currently a race condition in the Leshan client related to bootstrapping. In some cases, bootstrapping fails from the server’s perspective with BootstrapFailureCause.SEND_FINISH_FAILED
. The server doesn’t receive a reply to the bootstrap finish message.
The easiest way to explain the issue is to show the code: https://github.com/eclipse/leshan/blob/fbc01b848043cd4c8605bbd1d566728026300bbd/leshan-client-core/src/main/java/org/eclipse/leshan/client/servers/BootstrapHandler.java#L50-L64
The latch gets released before the response is sent to the server.
I’d assume that the fix would be to release the latch after the response has been sent in BootstrapResource
class (assuming exchange.respond
is synchronous):
https://github.com/eclipse/leshan/blob/fbc01b848043cd4c8605bbd1d566728026300bbd/leshan-client-cf/src/main/java/org/eclipse/leshan/client/californium/impl/BootstrapResource.java#L42-L50
the race condition currently (in 1.0.0-M9) happens when the endpoint gets destroyed after bootstrapping finishes from the clients perspective: https://github.com/eclipse/leshan/blob/fbc01b848043cd4c8605bbd1d566728026300bbd/leshan-client-cf/src/main/java/org/eclipse/leshan/client/californium/impl/CaliforniumEndpointsManager.java#L65-L70
that gets called from https://github.com/eclipse/leshan/blob/fbc01b848043cd4c8605bbd1d566728026300bbd/leshan-client-core/src/main/java/org/eclipse/leshan/client/servers/RegistrationEngine.java#L175-L180
Issue Analytics
- State:
- Created 5 years ago
- Comments:7 (5 by maintainers)
Top GitHub Comments
Thank you @sbernard31 . I’m sorry I missed your previous requests for feedback. I’ll let you know if there is any issues in the solution. I believe it’s all ok, but I’ll get it verified tomorrow
That’s what I currently implement, I provide a PR soon.