nasa/mct — pull request #150 by VWoeltjen (2013-08-16 18:40:10+00:00)
Title: [OSGi] Stop bundles at shutdown

Fixes #96

Existing OSGIRuntime interface had a "stopOSGI" method, but our implementation had no behavior (just a few lines commented out.) As a result, third-party plugins were not having their lifecycle methods invoked, meaning that important cleanup behavior could be missed.

This pull request resolves this issue by:
* Iterating through bundles and stopping them when stopOSGI is called. Note that this is done in reverse order to avoid errors (during startup, OSGi bundles are added first, but stopping these first causes subsequent bundle stops to raise errors due to SCR shutdown).
* After the preceding was fixed, FeedRenderingPool would sporadically throw exceptions. This was due to the use of services which were deactivated during the shutdown (which happens on a separate thread). Fixed by catching the relevant exception when attempting to retrieve the SubscriptionManager and returning null (which is already recognized in other code as indicating "no subscription manager available")
* Renamed "EquinoxOSGIRuntimeImpl" to "OSGIRuntimeImpl". Equinox is a different OSGi implementation that we have not used for some time (currently using Felix) so this name is misleading.
* Added unit test for OSGIRuntimeImpl, particularly for the new code path introduced.

Wrote or re-wrote unit tests (Y/N): Y
Ran entire suite of unit tests successfully (Y/N): Y
Verified bug fix with the described replication steps or verified the implementation meets the requirement cited (Y/N): Y
Code coverage requirements satisfied (new code=80%, changed code=at least as high as existing) (Y/N): Y
Code review date and attendees: Code review by pull request
Describe potential impact on other areas of the code: Activators, shutdown
Describe any test prerequisites for this fix (e.g., restart the database): N/A
For bugs marked "Regression - Yes", describe the cause of the regression: N/A
Did you modify any pom.xml file? If yes, did you thoroughly document your changes and reasons? N

Note that FeedRenderingPool change is not unit tested - the issue it addresses cannot be reliably replicated in a test setting