Fixed a bug when removing listeners; it was using the wrong index into the
listener array, so listeners were not being removed, which was inhibiting
garbage collection.


git-svn-id: https://svn.apache.org/repos/asf/incubator/felix/trunk@468402 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/framework/src/main/java/org/apache/felix/framework/util/EventDispatcher.java b/framework/src/main/java/org/apache/felix/framework/util/EventDispatcher.java
index 02199a4..24dff80 100644
--- a/framework/src/main/java/org/apache/felix/framework/util/EventDispatcher.java
+++ b/framework/src/main/java/org/apache/felix/framework/util/EventDispatcher.java
@@ -334,11 +334,11 @@
             {
                 // Check if the bundle associated with the current listener
                 // is the same as the specified bundle, if so remove the listener.
-                Bundle registeredBundle = (Bundle) listeners[LISTENER_BUNDLE_OFFSET];
+                Bundle registeredBundle = (Bundle) listeners[i + LISTENER_BUNDLE_OFFSET];
                 if (bundle.equals(registeredBundle))
                 {
-                    Class clazz = (Class) listeners[LISTENER_CLASS_OFFSET];
-                    EventListener l = (EventListener) listeners[LISTENER_OBJECT_OFFSET];
+                    Class clazz = (Class) listeners[i + LISTENER_CLASS_OFFSET];
+                    EventListener l = (EventListener) listeners[i + LISTENER_OBJECT_OFFSET];
                     removeListener(bundle, clazz, l);
                 }
             }
@@ -351,11 +351,11 @@
             {
                 // Check if the bundle associated with the current listener
                 // is the same as the specified bundle, if so remove the listener.
-                Bundle registeredBundle = (Bundle) listeners[LISTENER_BUNDLE_OFFSET];
+                Bundle registeredBundle = (Bundle) listeners[i + LISTENER_BUNDLE_OFFSET];
                 if (bundle.equals(registeredBundle))
                 {
-                    Class clazz = (Class) listeners[LISTENER_CLASS_OFFSET];
-                    EventListener l = (EventListener) listeners[LISTENER_OBJECT_OFFSET];
+                    Class clazz = (Class) listeners[i + LISTENER_CLASS_OFFSET];
+                    EventListener l = (EventListener) listeners[i + LISTENER_OBJECT_OFFSET];
                     removeListener(bundle, clazz, l);
                 }
             }
@@ -369,11 +369,11 @@
             {
                 // Check if the bundle associated with the current listener
                 // is the same as the specified bundle, if so remove the listener.
-                Bundle registeredBundle = (Bundle) listeners[LISTENER_BUNDLE_OFFSET];
+                Bundle registeredBundle = (Bundle) listeners[i + LISTENER_BUNDLE_OFFSET];
                 if (bundle.equals(registeredBundle))
                 {
-                    Class clazz = (Class) listeners[LISTENER_CLASS_OFFSET];
-                    EventListener l = (EventListener) listeners[LISTENER_OBJECT_OFFSET];
+                    Class clazz = (Class) listeners[i + LISTENER_CLASS_OFFSET];
+                    EventListener l = (EventListener) listeners[i + LISTENER_OBJECT_OFFSET];
                     removeListener(bundle, clazz, l);
                 }
             }
@@ -386,11 +386,11 @@
             {
                 // Check if the bundle associated with the current listener
                 // is the same as the specified bundle, if so remove the listener.
-                Bundle registeredBundle = (Bundle) listeners[LISTENER_BUNDLE_OFFSET];
+                Bundle registeredBundle = (Bundle) listeners[i + LISTENER_BUNDLE_OFFSET];
                 if (bundle.equals(registeredBundle))
                 {
-                    Class clazz = (Class) listeners[LISTENER_CLASS_OFFSET];
-                    EventListener l = (EventListener) listeners[LISTENER_OBJECT_OFFSET];
+                    Class clazz = (Class) listeners[i + LISTENER_CLASS_OFFSET];
+                    EventListener l = (EventListener) listeners[i + LISTENER_OBJECT_OFFSET];
                     removeListener(bundle, clazz, l);
                 }
             }