Fixed issue #49, duplication of subscription with different QoS

This commit is contained in:
andrea
2015-06-21 15:55:39 +02:00
parent 3deb903f3c
commit 932d2fb4cb
3 changed files with 28 additions and 3 deletions
@@ -30,8 +30,8 @@ class TreeNode {
TreeNode m_parent;
Token m_token;
List<TreeNode> m_children = new ArrayList<TreeNode>();
List<Subscription> m_subscriptions = new ArrayList<Subscription>();
List<TreeNode> m_children = new ArrayList<>();
List<Subscription> m_subscriptions = new ArrayList<>();
TreeNode(TreeNode parent) {
this.m_parent = parent;
@@ -51,7 +51,9 @@ class TreeNode {
return;
}
//remove existing subscription for same client and topic but different QoS
int existingSubIdx = Collections.binarySearch(m_subscriptions, s, new ClientIDComparator());
Comparator<Subscription> comparator = new ClientIDComparator();
Collections.sort(m_subscriptions, comparator);
int existingSubIdx = Collections.binarySearch(m_subscriptions, s, comparator);
if (existingSubIdx >= 0) {
m_subscriptions.remove(existingSubIdx);
}