Yes. If the state change lock acquire times out, then the state cant be changes and the bundle will not have been uninstalled. --
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: Ikuo Yamasaki <[email protected]> To: OSGi Developer Mail List <[email protected]> Date: 2011/06/21 03:10 Subject: Re: [osgi-dev] Q on Bundle#uninstall() Sent by: [email protected] Hi BJ, If Bundle.uninstall fails to obtain the state change lock, what will happen ? What I understand is - BundleException will be thrown and the bundle state will not be UNINSTALLED. Is it correct ? Best regards, Ikuo p.s. In R4.3 Core Spec, "9.1.5.37 public void uninstall( )" says ---- BundleException If the uninstall failed. This can occur if another thread is attempting to change this bundle’s state and does not complete in a timely manner. BundleException types thrown by this method include: BundleException.STATECHANGE_ERROR ---- On Fri, 27 May 2011 11:54:10 +0900 Ikuo Yamasaki <[email protected]> wrote: Ikuo> BJ, Ikuo> Ikuo> I got what you mean. Thanks as always! Ikuo> Ikuo> Ikuo Ikuo> Ikuo> On Thu, 26 May 2011 22:24:46 -0400 Ikuo> BJ Hargrave <[email protected]> wrote: Ikuo> Ikuo> BJ> Bundle.uninstall does not call Bundle.stop. It just says it stops the Ikuo> BJ> bundle as described in Bundle.stop. First Bundle.uninstall must obtain the Ikuo> BJ> state change lock. Once this occurs, the bundle can be stopped. Any Ikuo> BJ> exception thrown by BundleActivator.stop is published as a FrameworkEvent, Ikuo> BJ> but uninstall still completes normally. Only if the state change lock Ikuo> BJ> cannot be obtained in a reasonable time, will uninstall terminate with an Ikuo> BJ> exception. Ikuo> BJ> Ikuo> BJ> So case 1 never happens during uninstall since uninstall does not call Ikuo> BJ> stop. Ikuo> BJ> -- Ikuo> BJ> Ikuo> BJ> BJ Hargrave Ikuo> BJ> Senior Technical Staff Member, IBM Ikuo> BJ> OSGi Fellow and CTO of the OSGi Alliance Ikuo> BJ> [email protected] Ikuo> BJ> Ikuo> BJ> office: +1 386 848 1781 Ikuo> BJ> mobile: +1 386 848 3788 Ikuo> BJ> Ikuo> BJ> Ikuo> BJ> Ikuo> BJ> Ikuo> BJ> Ikuo> BJ> From: Ikuo Yamasaki <[email protected]> Ikuo> BJ> To: OSGi Developer Mail List <[email protected]> Ikuo> BJ> Date: 2011/05/26 20:53 Ikuo> BJ> Subject: Re: [osgi-dev] Q on Bundle#uninstall() Ikuo> BJ> Sent by: [email protected] Ikuo> BJ> Ikuo> BJ> Ikuo> BJ> Ikuo> BJ> Hi BJ, Ikuo> BJ> Ikuo> BJ> On Thu, 26 May 2011 18:46:25 -0400 Ikuo> BJ> BJ Hargrave <[email protected]> wrote: Ikuo> BJ> Ikuo> BJ> BJ> No. If stop completes with an exception, uninstall can still proceed. Ikuo> BJ> BJ> Uninstall can fail if the state change lock is held by another thread Ikuo> BJ> and Ikuo> BJ> BJ> that thread does not release the lock in some reasonable time. Ikuo> BJ> Ikuo> BJ> Spec says: Ikuo> BJ> -- quote ------------------------------------------------------- Ikuo> BJ> public void stop( int options ) throws BundleException Ikuo> BJ> Ikuo> BJ> 2 If this bundle is in the process of being activated or deactivated then Ikuo> BJ> this Ikuo> BJ> method must wait for activation or deactivation to complete before Ikuo> BJ> continuing. Ikuo> BJ> If this does not occur in a reasonable time, a BundleException is Ikuo> BJ> thrown to indicate this bundle was unable to be stopped. Ikuo> BJ> Ikuo> BJ> -- quote ------------------------------------------------------- Ikuo> BJ> Ikuo> BJ> It seems to me there exists two cases: Ikuo> BJ> Ikuo> BJ> Case1: Bundle.stop() throws BundleException due to the above reason. Ikuo> BJ> (Bundle#uninstall() does not throw BundleException) Ikuo> BJ> Ikuo> BJ> Case2: the state change lock is held by another thread and Ikuo> BJ> that thread does not release the lock in some reasonable time. Ikuo> BJ> (Bundle#uninstall() throws BundleException) Ikuo> BJ> Ikuo> BJ> Q1. Does Case2 include Case1 or not ? Ikuo> BJ> Ikuo> BJ> For me, yes. Ikuo> BJ> Ikuo> BJ> Q2. when should those check for Case2 be done in the following steps Ikuo> BJ> described in "6.1.4.35 public void uninstall( )" Ikuo> BJ> Ikuo> BJ> --begin quote--- Ikuo> BJ> The following steps are required to uninstall a bundle: Ikuo> BJ> 1 If this bundle’s state is UNINSTALLED then an IllegalStateException is Ikuo> BJ> thrown. Ikuo> BJ> 2 If this bundle’s state is ACTIVE, STARTING or STOPPING, this bundle is Ikuo> BJ> stopped as described in the Bundle.stop method. If Bundle.stop throws Ikuo> BJ> an exception, a Framework event of type FrameworkEvent.ERROR is Ikuo> BJ> fired containing the exception. Ikuo> BJ> 3 This bundle’s state is set to UNINSTALLED. Ikuo> BJ> 4 A bundle event of type BundleEvent.UNINSTALLED is fired. Ikuo> BJ> 5 This bundle and any persistent storage area provided for this bundle by Ikuo> BJ> the Framework are removed. Ikuo> BJ> --end quote--- Ikuo> BJ> Ikuo> BJ> Q3. Even in Case2, step 3-5 should be done. Is my understanding correct ? Ikuo> BJ> Ikuo> BJ> ======= Ikuo> BJ> Ikuo YAMASAKI Ikuo> BJ> Ikuo> BJ> Ikuo> BJ> _______________________________________________ Ikuo> BJ> OSGi Developer Mail List Ikuo> BJ> [email protected] Ikuo> BJ> https://mail.osgi.org/mailman/listinfo/osgi-dev Ikuo> BJ> Ikuo> Ikuo> ======= Ikuo> Ikuo YAMASAKI Ikuo> Ikuo> Ikuo> _______________________________________________ Ikuo> OSGi Developer Mail List Ikuo> [email protected] Ikuo> https://mail.osgi.org/mailman/listinfo/osgi-dev Ikuo> Ikuo> ======= Ikuo YAMASAKI _______________________________________________ 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
