eclipse-paho / eclipse-paho/paho.mqtt.java
ClientState checkForActivity calculates with nanos and millis
- Dominant language
- Java
- Stars
- 2.3k
- Forks
- 919
- PR merge metrics
- No merged PRs in 30d
Description
Bug is at least in 1.2.1.
The ClientStates checkForActivity method calculates e.g. the nextPingTime. In one of the else-cases (l. 787) it does:
nextPingTime = Math.max(1, getKeepAlive() - (time - lastOutboundActivity));
getKeepAlive delivers ms, while time and lastOutboundActivity are in ns. Therefore the result of this function is always 1, resulting in high frequented ping schedules.
PS: I strongly recommend naming all time variables with Ms/Nanos in the name to prevent such things.
E.g. in line 718, long nextPingTime = this.keepAlive; is done. this.keepAlive is in nanos, however, nextPingTime in the end has to be in ms again. It is always overwritten in the rest of the method, but this is also confusing.
Contributor guide
Assessment
This issue has not been assessed yet.