Commit 362ed2c5 authored by Guus der Kinderen's avatar Guus der Kinderen

OF-1008: Uniform handling of failed stanza routing

This commit makes handling of stanzas that could not be delivered uniform,
in regards to logging. Other than log levels and messages, this commit does
not make a functional change.
parent a67661c3
......@@ -20,13 +20,6 @@
package org.jivesoftware.openfire;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.TimerTask;
import java.util.concurrent.ConcurrentHashMap;
import org.dom4j.Element;
import org.jivesoftware.openfire.container.BasicModule;
import org.jivesoftware.openfire.handler.IQHandler;
......@@ -43,11 +36,10 @@ import org.jivesoftware.util.TaskEngine;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.xmpp.component.IQResultListener;
import org.xmpp.packet.IQ;
import org.xmpp.packet.JID;
import org.xmpp.packet.Message;
import org.xmpp.packet.Packet;
import org.xmpp.packet.PacketError;
import org.xmpp.packet.*;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
/**
* Routes iq packets throughout the server. Routing is based on the recipient
......@@ -468,21 +460,19 @@ public class IQRouter extends BasicModule {
}
/**
* Notification message indicating that a packet has failed to be routed to the receipient.
* Notification message indicating that a packet has failed to be routed to the recipient.
*
* @param receipient address of the entity that failed to receive the packet.
* @param packet IQ packet that failed to be sent to the receipient.
* @param recipient address of the entity that failed to receive the packet.
* @param packet IQ packet that failed to be sent to the recipient.
*/
public void routingFailed(JID receipient, Packet packet) {
IQ iq = (IQ) packet;
// If a route to the target address was not found then try to answer a
// service_unavailable error code to the sender of the IQ packet
if (IQ.Type.result != iq.getType() && IQ.Type.error != iq.getType()) {
Log.info("Packet sent to unreachable address " + packet.toXML());
sendErrorPacket(iq, PacketError.Condition.service_unavailable);
}
else {
Log.warn("Error or result packet could not be delivered " + packet.toXML());
public void routingFailed( JID recipient, Packet packet )
{
Log.debug( "IQ sent to unreachable address: " + packet.toXML() );
final IQ iq = (IQ) packet;
// If a route to the target address was not found then try to answer a service_unavailable error code to the sender of the IQ packet
if ( iq.isRequest() )
{
sendErrorPacket( iq, PacketError.Condition.service_unavailable );
}
}
......
......@@ -244,22 +244,23 @@ public class MessageRouter extends BasicModule {
* Notification message indicating that a packet has failed to be routed to the recipient.
*
* @param recipient address of the entity that failed to receive the packet.
* @param packet Message packet that failed to be sent to the recipient.
* @param packet Message packet that failed to be sent to the recipient.
*/
public void routingFailed(JID recipient, Packet packet) {
// If message was sent to an unavailable full JID of a user then retry using the bare JID
if (serverName.equals(recipient.getDomain()) && recipient.getResource() != null &&
userManager.isRegisteredUser(recipient.getNode())) {
Message msg = (Message)packet;
if (msg.getType().equals(Message.Type.chat)) {
routingTable.routePacket(recipient.asBareJID(), packet, false);
} else {
// Delegate to offline message strategy, which will either bounce or ignore the message depending on user settings.
messageStrategy.storeOffline((Message) packet);
}
} else {
// Just store the message offline
messageStrategy.storeOffline((Message) packet);
public void routingFailed( JID recipient, Packet packet )
{
log.debug( "Message sent to unreachable address: " + packet.toXML() );
final Message msg = (Message) packet;
if ( msg.getType().equals( Message.Type.chat ) && serverName.equals( recipient.getDomain() ) && recipient.getResource() != null
&& userManager.isRegisteredUser( recipient.getNode() ) )
{
// If message was sent to an unavailable full JID of a user then retry using the bare JID.
routingTable.routePacket( recipient.asBareJID(), packet, false );
}
else
{
// Delegate to offline message strategy, which will either bounce or ignore the message depending on user settings.
messageStrategy.storeOffline( (Message) packet );
}
}
}
......@@ -31,11 +31,7 @@ import org.jivesoftware.openfire.session.Session;
import org.jivesoftware.util.LocaleUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.xmpp.packet.JID;
import org.xmpp.packet.Message;
import org.xmpp.packet.Packet;
import org.xmpp.packet.PacketError;
import org.xmpp.packet.Presence;
import org.xmpp.packet.*;
/**
* <p>Route presence packets throughout the server.</p>
......@@ -219,12 +215,14 @@ public class PresenceRouter extends BasicModule {
}
/**
* Notification message indicating that a packet has failed to be routed to the receipient.
* Notification message indicating that a packet has failed to be routed to the recipient.
*
* @param receipient address of the entity that failed to receive the packet.
* @param packet Presence packet that failed to be sent to the receipient.
* @param recipient address of the entity that failed to receive the packet.
* @param packet Presence packet that failed to be sent to the recipient.
*/
public void routingFailed(JID receipient, Packet packet) {
public void routingFailed( JID recipient, Packet packet )
{
Log.debug( "Presence sent to unreachable address: " + packet.toXML() );
// presence packets are dropped silently
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment