powered by Jive Software

Possible bug in PacketInterceptor?

Hi,

I was writing a simple plugin and I tried to implement PacketInterceptor . After adding my implementing class to the listenerqueue, my function is being called 4 times for each message! I was wondering whether I added my class as listener twice. However, after debugging I found by default there is a single listener for the packets.

org.jivesoftware.openfire.filetransfer.DefaultFileTransferManager$MetaFileTransf erInterceptor@1e2481b

after adding my listener the number of listeners increased to 2. I am not sure why my function is being called four times for a single packet ?? the documentation states that for each packet the interceptor functions would be called only twice (before processing and after processing ). however before processing it is called 2 times and after processing it is called 2 times again.

2007.06.16 21:27:38 No of interceptors :2

2007.06.16 21:27:38

2007.06.16 21:27:38 Loading plugin search

2007.06.16 21:27:38 Registering component for domain: search

2007.06.16 21:27:38 No of interceptors :2

2007.06.16 21:27:38 Recieved packet :720-0 is processed?:false time:1182009458797

2007.06.16 21:27:38 No of interceptors :2

2007.06.16 21:27:38 Recieved packet :720-0 is processed?:false time:1182009458800

2007.06.16 21:27:38 No of interceptors :2

2007.06.16 21:27:38 Recieved packet :720-0 is processed?:true time:1182009458807

2007.06.16 21:27:38 No of interceptors :2

2007.06.16 21:27:38 Recieved packet :720-0 is processed?:true time:1182009458808

The above log shows that for each packet my function is called 4 times.

Am I doing a mistake anywhere ??? please let me know.

Could you check if this theory holds up in your code? A packet interceptor will intercept the packet twice when it arrives at the server: before it gets processed and after it was processed by the packet reader.

Usually, your packet is sent to some entity. When it leaves the server again, the packet interceptor will again intercept the packet twice: once just before the packet gets processed by whatever process is used to send the packet, and once after that has been done.

In all, your packet would be intercepted four times, just like you describe. You could use the boolean ‘‘incoming’’ to determine at what place in the entire route the packet was intercepted.

1 Like