wso2-dev/andes — pull request #24 by hastef88 (2014-07-23 12:43:24+00:00)
Title: Fix for intermittent NPE - Subscribing and Unsubscribing to a queue

The issue as reported by Sewwandi occurs when a subscriber listening to a queue with >10000 messages keeps dropping. A NullPointerException is thrown at QueueDeliveryWorker.sendMessagesToSubscriptions() method.

After some test runs, it was found that the "getUndeliveredMessagesOfQueue" method causes null objects to be added to the message collection. Further digging revealed that the ConcurrentHashMap "undeliveredMessagesMap" within QueueDeliveryWorker fails to retrieve messages accurately.

As a solution, A "TrulyConcurrentHashMap" class was created and used for "undeliveredMessagesMap". The class extends ConcurrentHashMap and adds further ReadWriteLocks to the collection.

In addition, HasithaH pointed out that "readButUndeliveredMessages" list also can suffer from above issue. ReadWriteLocks were added for that collection too.