diff --git a/parser/src/main/java/org/dna/mqtt/moquette/messaging/spi/impl/HawtDBStorageService.java b/parser/src/main/java/org/dna/mqtt/moquette/messaging/spi/impl/HawtDBStorageService.java index 5109cc89..8aec52e3 100644 --- a/parser/src/main/java/org/dna/mqtt/moquette/messaging/spi/impl/HawtDBStorageService.java +++ b/parser/src/main/java/org/dna/mqtt/moquette/messaging/spi/impl/HawtDBStorageService.java @@ -13,10 +13,7 @@ import org.slf4j.LoggerFactory; import java.io.File; import java.io.IOException; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; -import java.util.Map; +import java.util.*; import static org.dna.mqtt.moquette.messaging.spi.impl.SimpleMessaging.StoredMessage; @@ -39,7 +36,7 @@ public class HawtDBStorageService implements IStorageService { //persistent Map of clientID, list of Subscriptions //TODO move to Set to avoid double subscriptions - private SortedIndex> m_persistentSubscriptions; + private SortedIndex> m_persistentSubscriptions; public HawtDBStorageService() { String storeFile = Server.STORAGE_FILE_PATH; @@ -85,11 +82,10 @@ public class HawtDBStorageService implements IStorageService { } private void initPersistentSubscriptions() { - BTreeIndexFactory> indexFactory = - new BTreeIndexFactory>(); + BTreeIndexFactory> indexFactory = new BTreeIndexFactory>(); indexFactory.setKeyCodec(StringCodec.INSTANCE); - m_persistentSubscriptions = (SortedIndex>) m_multiIndexFactory.openOrCreate("subscriptions", indexFactory); + m_persistentSubscriptions = (SortedIndex>) m_multiIndexFactory.openOrCreate("subscriptions", indexFactory); } /** @@ -158,10 +154,10 @@ public class HawtDBStorageService implements IStorageService { public void addNewSubscription(Subscription newSubscription, String clientID) { if (!m_persistentSubscriptions.containsKey(clientID)) { - m_persistentSubscriptions.put(clientID, new ArrayList()); + m_persistentSubscriptions.put(clientID, new HashSet()); } - List subs = m_persistentSubscriptions.get(clientID); + Set subs = m_persistentSubscriptions.get(clientID); if (!subs.contains(newSubscription)) { subs.add(newSubscription); m_persistentSubscriptions.put(clientID, subs); @@ -174,7 +170,7 @@ public class HawtDBStorageService implements IStorageService { public List retrieveAllSubscriptions() { List allSubscriptions = new ArrayList(); - for (Map.Entry> entry : m_persistentSubscriptions) { + for (Map.Entry> entry : m_persistentSubscriptions) { allSubscriptions.addAll(entry.getValue()); } return allSubscriptions;