processed review comments on FELIX-3425.

git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1310294 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/dependencymanager/core/src/main/java/org/apache/felix/dm/impl/index/AdapterFilterIndex.java b/dependencymanager/core/src/main/java/org/apache/felix/dm/impl/index/AdapterFilterIndex.java
index 740e000..8d3975e 100644
--- a/dependencymanager/core/src/main/java/org/apache/felix/dm/impl/index/AdapterFilterIndex.java
+++ b/dependencymanager/core/src/main/java/org/apache/felix/dm/impl/index/AdapterFilterIndex.java
@@ -39,11 +39,13 @@
 import org.osgi.framework.ServiceListener;
 import org.osgi.framework.ServiceReference;
 
+import quicktime.std.music.ToneDescription;
+
 /**
  * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
  */
 public class AdapterFilterIndex implements FilterIndex, ServiceTrackerCustomizer {
-	// (&(objectClass=com.beinformed.product.platform.interfaces.Resource)(|(service.id=18233)(org.apache.felix.dependencymanager.aspect=18233)))
+	// (&(objectClass=foo.Bar)(|(service.id=18233)(org.apache.felix.dependencymanager.aspect=18233)))
     private static final String FILTER_START = "(&(" + Constants.OBJECTCLASS + "=";
     private static final String FILTER_SUBSTRING_0 = ")(|(" + Constants.SERVICE_ID + "=";
     private static final String FILTER_SUBSTRING_1 = ")(" + DependencyManager.ASPECT + "=";
@@ -91,7 +93,7 @@
     /** Returns a value object with the relevant filter data, or <code>null</code> if this filter was not valid. */
     private FilterData getFilterData(String clazz, String filter) {
         // something like:
-    	// (&(objectClass=com.beinformed.product.platform.interfaces.Resource)(|(service.id=18233)(org.apache.felix.dependencymanager.aspect=18233)))    	
+    	// (&(objectClass=foo.Bar)(|(service.id=18233)(org.apache.felix.dependencymanager.aspect=18233)))    	
         if ((filter != null)
             && (filter.startsWith(FILTER_START))
             && (filter.endsWith(FILTER_END))
@@ -125,13 +127,13 @@
         	SortedSet /* <ServiceReference> */ list = null;
         	synchronized (m_sidToServiceReferencesMap) {
         		list = (SortedSet) m_sidToServiceReferencesMap.get(Long.valueOf(data.serviceId));
+        		if (list != null) {
+        			Iterator iterator = list.iterator();
+        			while (iterator.hasNext()) {
+        				result.add((ServiceReference) iterator.next());
+        			}
+        		}
 			}
-            if (list != null) {
-                Iterator iterator = list.iterator();
-                while (iterator.hasNext()) {
-                    result.add((ServiceReference) iterator.next());
-                }
-            }
         }
         return result;
     }
@@ -139,16 +141,19 @@
     public void serviceChanged(ServiceEvent event) {
         ServiceReference reference = event.getServiceReference();
         Long sid = ServiceUtil.getServiceIdObject(reference);
+        List /* <ServiceListener> */ notificationList = new ArrayList();
         synchronized (m_sidToListenersMap) {
-            List /* <Integer, ServiceListener> */ list = (ArrayList) m_sidToListenersMap.get(sid);
+            List /* <ServiceListener> */ list = (ArrayList) m_sidToListenersMap.get(sid);
             if (list != null) {
-                Iterator iterator = list.iterator();
-                while (iterator.hasNext()) {
-                    ServiceListener listener = (ServiceListener) iterator.next();
-                    listener.serviceChanged(event);
-                }
+                notificationList.addAll(list);
             }
         }
+        // notify
+        Iterator iterator = notificationList.iterator();
+        while (iterator.hasNext()) {
+        	ServiceListener listener = (ServiceListener) iterator.next();
+        	listener.serviceChanged(event);
+        }
     }
 
     public void addServiceListener(ServiceListener listener, String filter) {
diff --git a/dependencymanager/core/src/main/java/org/apache/felix/dm/impl/index/AspectFilterIndex.java b/dependencymanager/core/src/main/java/org/apache/felix/dm/impl/index/AspectFilterIndex.java
index c16dada..70bf333 100644
--- a/dependencymanager/core/src/main/java/org/apache/felix/dm/impl/index/AspectFilterIndex.java
+++ b/dependencymanager/core/src/main/java/org/apache/felix/dm/impl/index/AspectFilterIndex.java
@@ -94,7 +94,7 @@
     /** Returns a value object with the relevant filter data, or <code>null</code> if this filter was not valid. */
     private FilterData getFilterData(String clazz, String filter) {
         // something like:
-        // (&(objectClass=com.beinformed.wiringtest.Model)(&(|(!(service.ranking=*))(service.ranking<=9))(|(service.id=37)(org.apache.felix.dependencymanager.aspect=37))))
+        // (&(objectClass=foo.Bar)(&(|(!(service.ranking=*))(service.ranking<=9))(|(service.id=37)(org.apache.felix.dependencymanager.aspect=37))))
         if ((filter != null)
             && (filter.startsWith(FILTER_START))
             && (filter.endsWith(FILTER_END))
@@ -132,16 +132,16 @@
         	SortedSet /* <ServiceReference> */ list = null;
         	synchronized (m_sidToServiceReferencesMap) {
         		list = (SortedSet) m_sidToServiceReferencesMap.get(Long.valueOf(data.serviceId));
+        		if (list != null) {
+        			Iterator iterator = list.iterator();
+        			while (iterator.hasNext()) {
+        				ServiceReference reference = (ServiceReference) iterator.next();
+        				if (ServiceUtil.getRanking(reference) <= data.ranking) {
+        					result.add(reference);
+        				}
+        			}
+        		}
 			}
-            if (list != null) {
-                Iterator iterator = list.iterator();
-                while (iterator.hasNext()) {
-                    ServiceReference reference = (ServiceReference) iterator.next();
-                    if (ServiceUtil.getRanking(reference) <= data.ranking) {
-                        result.add(reference);
-                    }
-                }
-            }
         }
         return result;
     }