Commit 64590b6e authored by Gaston Dombiak's avatar Gaston Dombiak Committed by gato

Fixed disco#info of components with several connections. JM-1401

git-svn-id: http://svn.igniterealtime.org/svn/repos/openfire/trunk@10581 b35dd754-fafc-0310-a699-88a17e54d16e
parent cb5e6812
...@@ -399,16 +399,16 @@ public class InternalComponentManager extends BasicModule implements ComponentMa ...@@ -399,16 +399,16 @@ public class InternalComponentManager extends BasicModule implements ComponentMa
* considered. * considered.
* *
* @param componentJID the jid mapped to the component. * @param componentJID the jid mapped to the component.
* @return the component with the specified id. * @return the list of components with the specified id.
*/ */
private Component getComponent(JID componentJID) { private List<Component> getComponents(JID componentJID) {
synchronized (routables) { synchronized (routables) {
if (componentJID.getNode() != null) { if (componentJID.getNode() != null) {
return null; return Collections.emptyList();
} }
RoutableComponents routable = routables.get(componentJID.getDomain()); RoutableComponents routable = routables.get(componentJID.getDomain());
if (routable != null) { if (routable != null) {
return routable.getNextComponent(); return routable.getComponents();
} }
else { else {
// Search again for those JIDs whose domain include the server name but this // Search again for those JIDs whose domain include the server name but this
...@@ -418,11 +418,11 @@ public class InternalComponentManager extends BasicModule implements ComponentMa ...@@ -418,11 +418,11 @@ public class InternalComponentManager extends BasicModule implements ComponentMa
if (index > -1) { if (index > -1) {
routable = routables.get(serverName.substring(0, index)); routable = routables.get(serverName.substring(0, index));
if (routable != null) { if (routable != null) {
return routable.getNextComponent(); return routable.getComponents();
} }
} }
} }
return null; return Collections.emptyList();
} }
} }
...@@ -503,9 +503,9 @@ public class InternalComponentManager extends BasicModule implements ComponentMa ...@@ -503,9 +503,9 @@ public class InternalComponentManager extends BasicModule implements ComponentMa
* @param packet the packet to process. * @param packet the packet to process.
*/ */
public void process(Packet packet) throws PacketException { public void process(Packet packet) throws PacketException {
Component component = getComponent(packet.getFrom()); List<Component> components = getComponents(packet.getFrom());
// Only process packets that were sent by registered components // Only process packets that were sent by registered components
if (component != null) { if (!components.isEmpty()) {
if (packet instanceof IQ && IQ.Type.result == ((IQ) packet).getType()) { if (packet instanceof IQ && IQ.Type.result == ((IQ) packet).getType()) {
IQ iq = (IQ) packet; IQ iq = (IQ) packet;
Element childElement = iq.getChildElement(); Element childElement = iq.getChildElement();
...@@ -522,6 +522,7 @@ public class InternalComponentManager extends BasicModule implements ComponentMa ...@@ -522,6 +522,7 @@ public class InternalComponentManager extends BasicModule implements ComponentMa
XMPPServer.getInstance().getIQDiscoItemsHandler().addComponentItem(packet.getFrom() XMPPServer.getInstance().getIQDiscoItemsHandler().addComponentItem(packet.getFrom()
.toBareJID(), .toBareJID(),
identity.attributeValue("name")); identity.attributeValue("name"));
for (Component component : components) {
if (component instanceof ComponentSession.ExternalComponent) { if (component instanceof ComponentSession.ExternalComponent) {
ComponentSession.ExternalComponent externalComponent = ComponentSession.ExternalComponent externalComponent =
(ComponentSession.ExternalComponent) component; (ComponentSession.ExternalComponent) component;
...@@ -530,8 +531,9 @@ public class InternalComponentManager extends BasicModule implements ComponentMa ...@@ -530,8 +531,9 @@ public class InternalComponentManager extends BasicModule implements ComponentMa
externalComponent.setCategory(identity.attributeValue("category")); externalComponent.setCategory(identity.attributeValue("category"));
} }
} }
}
catch (Exception e) { catch (Exception e) {
Log.error("Error processing disco packet of component: " + component + Log.error("Error processing disco packet of components: " + components +
" - " + packet.toXML(), e); " - " + packet.toXML(), e);
} }
// Store the IQ disco#info returned by the component // Store the IQ disco#info returned by the component
...@@ -562,11 +564,10 @@ public class InternalComponentManager extends BasicModule implements ComponentMa ...@@ -562,11 +564,10 @@ public class InternalComponentManager extends BasicModule implements ComponentMa
private static class RoutableComponents implements RoutableChannelHandler { private static class RoutableComponents implements RoutableChannelHandler {
private JID jid; private JID jid;
final private List<Component> components; final private List<Component> components = new ArrayList<Component>();
public RoutableComponents(JID jid, Component component) { public RoutableComponents(JID jid, Component component) {
this.jid = jid; this.jid = jid;
this.components = new ArrayList<Component>();
addComponent(component); addComponent(component);
} }
...@@ -600,7 +601,7 @@ public class InternalComponentManager extends BasicModule implements ComponentMa ...@@ -600,7 +601,7 @@ public class InternalComponentManager extends BasicModule implements ComponentMa
return components; return components;
} }
public Component getNextComponent() { private Component getNextComponent() {
Component component; Component component;
synchronized (components) { synchronized (components) {
component = components.get(0); component = components.get(0);
......
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