PacketReader bug

Hello,

I think I have found a bug in smack. In the class PacketReader, there’‘s a function called processListeners that go through all the packet listener wrappers to see if there are some packets to notify. Here’'s the loop:

for (int i=0; i<size; i++) {

ListenerWrapper wrapper = (ListenerWrapper)listeners.get(i);

if (wrapper != null) {

processedPacket = processedPacket || wrapper.notifyListener();

}

}

Unfortunately, what happens is that once processedPacket gets set, the notifyListener for the successive listeners never get called during that loop because when using a ||, it will not evaluate the rest of the test if something is found to be true.

So what happens is that only when the first listener has finished sending all the packets, that it will start sending the packets of the next listeners.

To fix the problem, the loop should be like this :

for (int i=0; i<size; i++) {

ListenerWrapper wrapper = (ListenerWrapper)listeners.get(i);

if (wrapper != null) {

processedPacket = wrapper.notifyListener() || processedPacket;

}

}

This will guarantee that all listeners get a chance to notify a pending packet.