FELIX-3057 fixed the bug

git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1151402 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/dependencymanager/core/src/main/java/org/apache/felix/dm/impl/index/BundleContextInterceptor.java b/dependencymanager/core/src/main/java/org/apache/felix/dm/impl/index/BundleContextInterceptor.java
index c76cbd4..51cc43d 100644
--- a/dependencymanager/core/src/main/java/org/apache/felix/dm/impl/index/BundleContextInterceptor.java
+++ b/dependencymanager/core/src/main/java/org/apache/felix/dm/impl/index/BundleContextInterceptor.java
@@ -89,6 +89,9 @@
                     }
                 }
             }
+            if (result == null || result.size() == 0) {
+                return null;
+            }
             return (ServiceReference[]) result.toArray(new ServiceReference[result.size()]);
         }
         else {
@@ -102,6 +105,9 @@
         FilterIndex filterIndex = m_cache.hasFilterIndexFor(clazz, filter);
         if (filterIndex != null) {
             List /* <ServiceReference> */ result = filterIndex.getAllServiceReferences(clazz, filter);
+            if (result == null || result.size() == 0) {
+                return null;
+            }
             return (ServiceReference[]) result.toArray(new ServiceReference[result.size()]);
         }
         else {