Let's consider such situation. BundleA provides a Foo service and BundleB uses Foo service. In some point of time, BundleB is executing code foo.foo()
- method foo of Foo service is executing but hasn't yet completed.
What happens if at this time (while foo method is still executing) OSGI framework gets command to stop BunldeA? Will framework wait until method foo is completed? As OSGi framework I use Felix.
I'm assuming that bundle B is invoking the method on one thread and then someone else sends a command to the framework to stop bundle A on a different thread.
The framework will not wait until the call completes. It will stop the bundle, which also means that (even if the bundle does not explicitly do this) the service will be unregistered. The call in progress will simply continue. Depending on what it still does, it might either complete normally or, at some point, throw a (runtime) exception to the caller (all depending on the actual implementation of that method).