Skip to content

Commit

Permalink
OF-818 Move isEmpty() check before filtering for highest prio sessions
Browse files Browse the repository at this point in the history
  • Loading branch information
sco0ter committed Jun 11, 2014
1 parent 007dd25 commit 20d4820
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/java/org/jivesoftware/openfire/spi/RoutingTableImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -528,6 +528,12 @@ private boolean routeToBareJID(JID recipientJID, Message packet, boolean isPriva
// Get the sessions with non-negative priority for message carbons processing.
List<ClientSession> nonNegativePrioritySessions = getNonNegativeSessions(sessions, 0);

if (nonNegativePrioritySessions.isEmpty()) {
// No session is available so store offline
Log.debug("Unable to route packet. No session is available so store offline. {} ", packet.toXML());
return false;
}

// Get the highest priority sessions for normal processing.
List<ClientSession> highestPrioritySessions = getHighestPrioritySessions(nonNegativePrioritySessions);

Expand All @@ -539,12 +545,7 @@ private boolean routeToBareJID(JID recipientJID, Message packet, boolean isPriva
}
}

if (highestPrioritySessions.isEmpty()) {
// No session is available so store offline
Log.debug("Unable to route packet. No session is available so store offline. {} ", packet.toXML());
return false;
}
else if (highestPrioritySessions.size() == 1) {
if (highestPrioritySessions.size() == 1) {
// Found only one session so deliver message (if it hasn't already been processed because it has message carbons enabled)
if (!shouldCarbonCopyToResource(highestPrioritySessions.get(0), packet, isPrivate)) {
highestPrioritySessions.get(0).process(packet);
Expand Down

0 comments on commit 20d4820

Please sign in to comment.