We use the non-capitalized term "exception" to mean any Throwable.
As for bundle created threads, the framework as nothing do with the termination of those threads either normally or abnormally. It is up to the thread creator to prepare for abnormal thread termination. -- BJ Hargrave Senior Technical Staff Member, IBM OSGi Fellow and CTO of the OSGi Alliance [email protected] office: +1 386 848 1781 mobile: +1 386 848 3788 From: "Cornelius, Martin (DWBI)" <[email protected]> To: <[email protected]> Date: 2009/02/16 06:55 Subject: [osgi-dev] Question about RuntimeException and Error handling in OSGi Sent by: [email protected] I'm wondering about this question : Is there is a default way in which uncaught throwables, i.e. instances of RuntimeException or Error, are handled within OSGi ? So fa i found partly answers of this question: - In paragraph 4.3.6 of the core spec, i found this statement: If the start(BundleContext) method throws an exception, the Framework must mark the bundle as stopped and send out STOPPING and STOPPED events but it must not call the Bundle Activator stop(BundleContext) method. - The method stop(BundleContext) may also throw an execption, but i found no hint in the spec what should happen in this case. However, the javadoc of the core API states the following: if this method throws an exception, the bundle is still marked as stopped, and the Framework will remove the bundle's listeners, unregister all services registered by the bundle, and release all services used by the bundle. This leaves some cases unspecified: 1.) what should happen, if an Error is thrown from start(BundleContext) or stop(BundleContext). 2.) what should happen, if some 'worker thread' started internally within a bundle throws an uncaught RuntimeException or an Error from it's run() method ? To me, it looks in many cases reasonable to shut down the complete VM if such uncaught exceptions occur, because it might be in an unforeseen, inconsistent state. However (at least with ApacheFelix) this does not happen by default. Of course i can code this explicitely whenever a thread is started in my code, but this does not help me with third party libraries (like Jacorb or QUARTZ), that create threads internally. For this reason, i would like to install a general 'uncaughtException' handler for a specific bundle or the complete OSGi framework. I have been searching the spec and the mailing lists on how to achieve this behaviour, but found nothing so far. Have i overlooked something, or have these cases intentionally been left out from the spec ? thanks in advance for any hints, Martin ************************************************ The information contained in, or attached to, this e-mail, may contain confidential information and is intended solely for the use of the individual or entity to whom they are addressed and may be subject to legal privilege. If you have received this e-mail in error you should notify the sender immediately by reply e-mail, delete the message from your system and notify your system manager. Please do not copy it for any purpose, or disclose its contents to any other person. The views or opinions presented in this e-mail are solely those of the author and do not necessarily represent those of the company. The recipient should check this e-mail and any attachments for the presence of viruses. The company accepts no liability for any damage caused, directly or indirectly, by any virus transmitted in this email. ************************************************ _______________________________________________ OSGi Developer Mail List [email protected] https://mail.osgi.org/mailman/listinfo/osgi-dev
_______________________________________________ OSGi Developer Mail List [email protected] https://mail.osgi.org/mailman/listinfo/osgi-dev
