Skip to content

Commit

Permalink
Fix NullPointerException when session.recover() is called without sub…
Browse files Browse the repository at this point in the history
…scribing to a queue.
  • Loading branch information
a5anka committed Oct 14, 2016
1 parent dd1d712 commit 7d6fff7
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
import org.wso2.andes.kernel.disruptor.inbound.InboundSubscriptionEvent;
import org.wso2.andes.kernel.disruptor.inbound.InboundTransactionEvent;
import org.wso2.andes.kernel.disruptor.inbound.PubAckHandler;
import org.wso2.andes.kernel.slot.Slot;
import org.wso2.andes.kernel.subscription.AndesSubscription;
import org.wso2.andes.kernel.subscription.AndesSubscriptionManager;
import org.wso2.andes.kernel.subscription.StorageQueue;
Expand Down Expand Up @@ -150,6 +149,14 @@ private Andes() {
public void recoverMessage(UUID channelID) throws AndesException {
AndesSubscription subscription = AndesContext.getInstance().
getAndesSubscriptionManager().getSubscriptionByProtocolChannel(channelID);

// Subscription can be null if we send a recover call without subscribing. In this case we do not have
// to recover any messages. Therefore print a log and return.
if (null == subscription) {
log.warn("Cannot handle recover. No subscriptions found for channel " + channelID);
return;
}

subscription.recoverMessages();
}

Expand Down

0 comments on commit 7d6fff7

Please sign in to comment.