Commit 19d41e6f authored by Gaston Dombiak's avatar Gaston Dombiak Committed by gato

Optimization. JM-476

git-svn-id: http://svn.igniterealtime.org/svn/repos/messenger/trunk@3142 b35dd754-fafc-0310-a699-88a17e54d16e
parent 465c457c
...@@ -214,21 +214,25 @@ public class InterceptorManager { ...@@ -214,21 +214,25 @@ public class InterceptorManager {
throws PacketRejectedException throws PacketRejectedException
{ {
// Invoke the global interceptors for this packet // Invoke the global interceptors for this packet
for (PacketInterceptor interceptor : globalInterceptors) { // Checking if collection is empty to prevent creating an iterator of
try { // a CopyOnWriteArrayList that is an expensive operation
interceptor.interceptPacket(packet, session, read, processed); if (!globalInterceptors.isEmpty()) {
} for (PacketInterceptor interceptor : globalInterceptors) {
catch (PacketRejectedException e) { try {
if (processed) { interceptor.interceptPacket(packet, session, read, processed);
Log.error("Post interceptor cannot reject packet.", e);
} }
else { catch (PacketRejectedException e) {
// Throw this exception since we don't really want to catch it if (processed) {
throw e; Log.error("Post interceptor cannot reject packet.", e);
}
else {
// Throw this exception since we don't really want to catch it
throw e;
}
}
catch (Exception e) {
Log.error("Error in interceptor", e);
} }
}
catch (Exception e) {
Log.error("Error in interceptor", e);
} }
} }
// Invoke the interceptors that are related to the address of the session // Invoke the interceptors that are related to the address of the session
......
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