In case that a module imports a package from a service provider and the provider doesn't import the package we allow the requester to get the service in case he is bound to any older revision of the module. This is wrong, we need to make sure the requester is wired to the current module of the provider else the requester might get ClassCastExceptions. Thanks to Peter Doornbusch for pointing out this bug.

git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@576140 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/framework/src/main/java/org/apache/felix/framework/ServiceReferenceImpl.java b/framework/src/main/java/org/apache/felix/framework/ServiceReferenceImpl.java
index 6ac93af..1778a93 100644
--- a/framework/src/main/java/org/apache/felix/framework/ServiceReferenceImpl.java
+++ b/framework/src/main/java/org/apache/felix/framework/ServiceReferenceImpl.java
@@ -1,4 +1,4 @@
-/* 
+/*
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements.  See the NOTICE file
  * distributed with this work for additional information
@@ -33,7 +33,7 @@
         m_registration = reg;
         m_bundle = bundle;
     }
-    
+
     protected ServiceRegistrationImpl getServiceRegistration()
     {
         return m_registration;
@@ -140,7 +140,7 @@
         // refernce. In case 3, we simply compare the exporting
         // modules from the package wiring to determine if we need
         // to filter the service reference.
-        
+
         // Case 1: Always include service reference.
         if (requesterWire == null)
         {
@@ -171,6 +171,13 @@
                     allow = false;
                 }
             }
+            else
+            {
+                // O.k. the provider is the exporter of the requester's package, now check
+                // if the requester is wired to the latest version of the provider, if so
+                // then allow else don't (the provider has been updated but not refreshed).
+                allow = ((FelixBundle) m_bundle).getInfo().getCurrentModule() == requesterWire.getExporter();
+            }
         }
         // Case 3: Include service reference if the wires have the
         // same source module.