Hello,

I have a test case in Apache Tuscany which fails intermittently when run
along with a lot of other OSGi-based tests under Felix.

I have three bundles A, B and C with distinct packages contained inside
them.

BundleA exports PackageA.
BundleB imports PackageA.

I use the system bundleContext to register a service with interface
PackageA.ClassA. The interface class for the service is loaded using
BundleB.loadClass("PackageA.ClassA"). BundleB looks up the registry to find
this service (the actual service object  registered is a Java proxy with the
interface PackageA.ClassA).

It works fine most of the time. BundleB finds the proxy service using
getServiceReferences since the provider (system bundle) does not have a wire
to PackageA, and the class of the object being looked up is the same as the
one visible to BundleB.

But once in a while, the test does not find the proxy. Sometimes it finds a
proxy and then throws ClassCastException when BundleB typecasts the object
returned to (PackageA.ClassA). But there is only one copy of the class
installed into the OSGi runtime.

There are other bundles which don't contain PackageA which are installed and
uninstalled while the test is running, but I am not sure if these should
affect BundleA/BundleB given that their import/exports are not satisfied by
these other bundles.

Is there any circumstance under which the class that is visible to BundleB
would get reloaded when neither BundleB that is importing the package and
BundleA that is exporting the package have not been restarted? In other
words, is BundleB.loadClass("PackageA.ClassA") always guaranteed to return
the same class if the bundle exporting PackageA is not uninstalled, and no
new bundles are added which export PackageA?



Thank you...

Regards,

Rajini

Reply via email to