Browse Source

fix: delay LwM2M client stop in FW update to prevent Execute response race

When Execute RPC is sent to FW Update resource (/5/0/2), the test client's
startUpdating() scheduled the client stop with 0 delay. This caused a race
where the client stopped before the CoAP Execute response (2.04 Changed)
was delivered to the server, resulting in RequestCanceledException and
INTERNAL_SERVER_ERROR instead of CHANGED.

Adding a 1-second delay before leshanClient.stop() ensures the CoAP
response is transmitted and received before the client disconnects, fixing
the flaky testExecuteUpdateFWById_Result_CHANGED test.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
pull/15159/head
Sergey Matvienko 5 months ago
parent
commit
455f62eaef
  1. 2
      application/src/test/java/org/thingsboard/server/transport/lwm2m/client/FwLwM2MDevice.java

2
application/src/test/java/org/thingsboard/server/transport/lwm2m/client/FwLwM2MDevice.java

@ -193,7 +193,7 @@ public class FwLwM2MDevice extends BaseInstanceEnabler implements Destroyable {
} catch (Exception e) {
log.error("Error during firmware update", e);
}
}, 0, TimeUnit.SECONDS); // start immediately, without further delay
}, 1, TimeUnit.SECONDS); // delay 1 sec to allow CoAP Execute response to be delivered before client stops
}
protected void setLeshanClient(LeshanClient leshanClient) {

Loading…
Cancel
Save