Fixed bug #143 avoid publication try to disconnected clients
This commit is contained in:
@@ -214,6 +214,10 @@ public class SubscriptionsStore {
|
|||||||
for (ClientTopicCouple matchingCouple : matchingSubs) {
|
for (ClientTopicCouple matchingCouple : matchingSubs) {
|
||||||
Subscription existingSub = subsForClient.get(matchingCouple.clientID);
|
Subscription existingSub = subsForClient.get(matchingCouple.clientID);
|
||||||
Subscription sub = m_sessionsStore.getSubscription(matchingCouple);
|
Subscription sub = m_sessionsStore.getSubscription(matchingCouple);
|
||||||
|
if (sub == null) {
|
||||||
|
//if the m_sessionStore hasn't the sub because the client disconnected
|
||||||
|
continue;
|
||||||
|
}
|
||||||
//update the selected subscriptions if not present or if has a greater qos
|
//update the selected subscriptions if not present or if has a greater qos
|
||||||
if (existingSub == null || existingSub.getRequestedQos().byteValue() < sub.getRequestedQos().byteValue()) {
|
if (existingSub == null || existingSub.getRequestedQos().byteValue() < sub.getRequestedQos().byteValue()) {
|
||||||
subsForClient.put(matchingCouple.clientID, sub);
|
subsForClient.put(matchingCouple.clientID, sub);
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ import org.junit.Test;
|
|||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import java.io.EOFException;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
@@ -255,4 +256,17 @@ public class ServerIntegrationEmbeddedPublishTest {
|
|||||||
//Verify
|
//Verify
|
||||||
verifyMessageIsReceivedSuccessfully();
|
verifyMessageIsReceivedSuccessfully();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test(expected = EOFException.class)
|
||||||
|
public void testClientSubscribeAfterDisconnected() throws Exception {
|
||||||
|
LOG.info("*** testClientSubscribeAfterDisconnected ***");
|
||||||
|
|
||||||
|
subscribeToWithQos("foo", QoS.AT_MOST_ONCE);
|
||||||
|
m_subscriber.disconnect();
|
||||||
|
|
||||||
|
internalPublishToWithQosAndRetained("foo", QOSType.MOST_ONE, false);
|
||||||
|
|
||||||
|
//verifyMessageIsReceivedSuccessfully();
|
||||||
|
m_subscriber.receive(2, TimeUnit.MILLISECONDS);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user