Minor changes

This commit is contained in:
andsel
2018-11-08 22:28:29 +01:00
parent e10619813a
commit dd8bad7480
3 changed files with 15 additions and 18 deletions
@@ -228,8 +228,10 @@ final class MQTTConnection {
void handleConnectionLost() { void handleConnectionLost() {
String clientID = NettyUtils.clientID(channel); String clientID = NettyUtils.clientID(channel);
if (clientID != null && !clientID.isEmpty()) { if (clientID == null || clientID.isEmpty()) {
LOG.info("Notifying connection lost event. CId = {}, channel: {}", clientID, channel); return;
}
LOG.info("Notifying connection lost event. CId: {}, channel: {}", clientID, channel);
Session session = sessionRegistry.retrieve(clientID); Session session = sessionRegistry.retrieve(clientID);
if (session.hasWill()) { if (session.hasWill()) {
postOffice.fireWill(session.getWill()); postOffice.fireWill(session.getWill());
@@ -241,9 +243,6 @@ final class MQTTConnection {
} }
connected = false; connected = false;
} }
//?? this breaks test elapseKeepAliveTime
// channel.close().addListener(CLOSE_ON_FAILURE);
}
void sendConnAck(boolean isSessionAlreadyPresent) { void sendConnAck(boolean isSessionAlreadyPresent) {
connected = true; connected = true;
@@ -37,9 +37,7 @@ public class MoquetteIdleTimeoutHandler extends ChannelDuplexHandler {
IdleState e = ((IdleStateEvent) evt).state(); IdleState e = ((IdleStateEvent) evt).state();
if (e == IdleState.READER_IDLE) { if (e == IdleState.READER_IDLE) {
LOG.info("Firing channel inactive event. MqttClientId = {}.", NettyUtils.clientID(ctx.channel())); LOG.info("Firing channel inactive event. MqttClientId = {}.", NettyUtils.clientID(ctx.channel()));
// fire a channelInactive to trigger publish of Will // fire a close that then fire channelInactive to trigger publish of Will
//??
// ctx.fireChannelInactive();
ctx.close().addListener(CLOSE_ON_FAILURE); ctx.close().addListener(CLOSE_ON_FAILURE);
} }
} else { } else {
@@ -74,7 +74,7 @@ public class ServerLowlevelMessagesIntegrationTests {
} }
@Test @Test
public void elapseKeepAliveTime() throws InterruptedException { public void elapseKeepAliveTime() {
int keepAlive = 2; // secs int keepAlive = 2; // secs
MqttConnectMessage connectMessage = createConnectMessage("FAKECLNT", keepAlive); MqttConnectMessage connectMessage = createConnectMessage("FAKECLNT", keepAlive);