From 3ac692a7c7625699645f7edc6fd3605dafc492ac Mon Sep 17 00:00:00 2001 From: andsel Date: Thu, 17 Nov 2016 22:50:04 +0100 Subject: [PATCH] Removed unuseful sessionStolen attribute from channel --- .../io/moquette/server/netty/NettyMQTTHandler.java | 9 +-------- .../java/io/moquette/server/netty/NettyUtils.java | 4 ++-- .../java/io/moquette/spi/impl/ProtocolProcessor.java | 11 ++--------- 3 files changed, 5 insertions(+), 19 deletions(-) diff --git a/broker/src/main/java/io/moquette/server/netty/NettyMQTTHandler.java b/broker/src/main/java/io/moquette/server/netty/NettyMQTTHandler.java index ae556e69..5495d08e 100644 --- a/broker/src/main/java/io/moquette/server/netty/NettyMQTTHandler.java +++ b/broker/src/main/java/io/moquette/server/netty/NettyMQTTHandler.java @@ -90,14 +90,7 @@ public class NettyMQTTHandler extends ChannelInboundHandlerAdapter { public void channelInactive(ChannelHandlerContext ctx) throws Exception { String clientID = NettyUtils.clientID(ctx.channel()); if (clientID != null && !clientID.isEmpty()) { - //if the channel was of a correctly connected client, inform messaging - //else it was of a not completed CONNECT message or sessionStolen - boolean stolen = false; - Boolean stolenAttr = NettyUtils.sessionStolen(ctx.channel()); - if (stolenAttr != null && stolenAttr == Boolean.TRUE) { - stolen = true; - } - m_processor.processConnectionLost(clientID, stolen, ctx.channel()); + m_processor.processConnectionLost(clientID, ctx.channel()); } ctx.close(); } diff --git a/broker/src/main/java/io/moquette/server/netty/NettyUtils.java b/broker/src/main/java/io/moquette/server/netty/NettyUtils.java index 1450f4a0..91e64772 100644 --- a/broker/src/main/java/io/moquette/server/netty/NettyUtils.java +++ b/broker/src/main/java/io/moquette/server/netty/NettyUtils.java @@ -73,7 +73,7 @@ public class NettyUtils { return (String) channel.attr(NettyUtils.ATTR_KEY_USERNAME).get(); } - @Deprecated + /*@Deprecated public static void sessionStolen(Channel channel, boolean value) { channel.attr(NettyUtils.ATTR_KEY_SESSION_STOLEN).set(value); } @@ -81,5 +81,5 @@ public class NettyUtils { @Deprecated public static Boolean sessionStolen(Channel channel) { return (Boolean) channel.attr(NettyUtils.ATTR_KEY_SESSION_STOLEN).get(); - } + }*/ } diff --git a/broker/src/main/java/io/moquette/spi/impl/ProtocolProcessor.java b/broker/src/main/java/io/moquette/spi/impl/ProtocolProcessor.java index 663df965..2017bb5b 100644 --- a/broker/src/main/java/io/moquette/spi/impl/ProtocolProcessor.java +++ b/broker/src/main/java/io/moquette/spi/impl/ProtocolProcessor.java @@ -815,18 +815,11 @@ public class ProtocolProcessor { return true; } - public void processConnectionLost(String clientID, boolean sessionStolen, Channel channel) { + public void processConnectionLost(String clientID, Channel channel) { ConnectionDescriptor oldConnDescr = new ConnectionDescriptor(clientID, channel, true); connectionDescriptors.remove(clientID, oldConnDescr); - //If already removed a disconnect message was already processed for this clientID - if (sessionStolen) { - //de-activate the subscriptions for this ClientID - ClientSession clientSession = m_sessionsStore.sessionForClient(clientID); - //TODO it's needed? clientSession.deactivate(); - LOG.info("Lost connection with client <{}>", clientID); - } //publish the Will message (if any) for the clientID - if (!sessionStolen && m_willStore.containsKey(clientID)) { + if (m_willStore.containsKey(clientID)) { WillMessage will = m_willStore.get(clientID); forwardPublishWill(will, clientID); m_willStore.remove(clientID);