Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 337228 - CompositeBundle frameworks revert to INSTALLED state after a framework restart
Summary: CompositeBundle frameworks revert to INSTALLED state after a framework restart
Status: RESOLVED FIXED
Alias: None
Product: Equinox
Classification: Eclipse Project
Component: Framework (show other bugs)
Version: unspecified   Edit
Hardware: PC Mac OS X - Carbon (unsup.)
: P3 normal (vote)
Target Milestone: 3.7 M6   Edit
Assignee: Thomas Watson CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-02-15 11:21 EST by Alasdair Nottingham CLA
Modified: 2011-02-21 15:54 EST (History)
1 user (show)

See Also:


Attachments
patch (1.05 KB, patch)
2011-02-15 15:33 EST, Thomas Watson CLA
no flags Details | Diff
patch (1.90 KB, patch)
2011-02-21 15:52 EST, Thomas Watson CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Alasdair Nottingham CLA 2011-02-15 11:21:01 EST
Build Identifier: org.eclipse.osgi_3.7.0.v20101022.jar

When you create a CompositeBundle the bundle enters RESOLVED state. There is also a framework inside the CompositeBundle and this framework starts off in the INSTALLED state. This can be started. Once started, or initialized, the framework has a BundleContext.

If you restart the framework you would usually expect the framework in the CompositeBundle to be in the state it was when the parent framework was shutdown. Instead the framework reverts to the INSTALLED state.

I suspect the state of the child framework is not cached.

Reproducible: Always

Steps to Reproduce:
1.Create CompositeBundle
2.Start CompositeBundle
3.Restart the framework
4.Attempt to get the composite bundle frameworks BundleContext.
Comment 1 Thomas Watson CLA 2011-02-15 11:26:54 EST
investigate for M6.
Comment 2 Thomas Watson CLA 2011-02-15 15:06:56 EST
I reproduced the issue.  It is only reproduced if you never cause the composite bundle to resolve.  Causing the composite to resolve by using PackageAdmin.resolveBundles or starting the composite will force it to resolve.  On restart if the composite bundle is resolved then the composite bundle will be initialized properly.
Comment 3 Thomas Watson CLA 2011-02-15 15:19:36 EST
My previous comment was incorrect.  The composite has to be persistently started.  Simply having it resolved is not good enough.
Comment 4 Alasdair Nottingham CLA 2011-02-15 15:22:26 EST
(In reply to comment #3)
> My previous comment was incorrect.  The composite has to be persistently
> started.  Simply having it resolved is not good enough.

My CompositeBundle reaches ACTIVE state prior to the restart. We appear to call start(Bundle.START_ACTIVATION_POLICY). Is this a persistent start?
Comment 5 Thomas Watson CLA 2011-02-15 15:33:21 EST
Created attachment 189042 [details]
patch

Here is a simple fix that ensures the composite framework is initialized on restart no matter what the state of the CompositeBundle is in.  The drawback to this is that all composite frameworks will now need to be aggressively initialized which may be a hit on performance.
Comment 6 Thomas Watson CLA 2011-02-15 15:35:27 EST
A possible workaround is to always call CompositeBundle.getCompositeFramework().init() before getting the context.  Calling init() on an already initialized framework should be a no-op.
Comment 7 Thomas Watson CLA 2011-02-17 15:06:50 EST
Given the fact that CompositeBundle is dead, there is a workaround, and I am unsure of the impacts of early initialization of the child frameworks: I think the best thing to do here is nothing.
Comment 8 Alasdair Nottingham CLA 2011-02-18 05:49:40 EST
(In reply to comment #6)
> A possible workaround is to always call
> CompositeBundle.getCompositeFramework().init() before getting the context. 
> Calling init() on an already initialized framework should be a no-op.

This is a hugely invasive change to make and is likely to be very error prone
Comment 9 Thomas Watson CLA 2011-02-21 14:04:22 EST
(In reply to comment #8)
> (In reply to comment #6)
> > A possible workaround is to always call
> > CompositeBundle.getCompositeFramework().init() before getting the context. 
> > Calling init() on an already initialized framework should be a no-op.
> 
> This is a hugely invasive change to make and is likely to be very error prone

I am wondering if this is an inflated claim.  I hope you don't have 100s of lines of code that all call CompositeBundle.getCompositeFramework().getBundleContext() I was really hoping it was a very isolated piece of code that dealt with the composite framework.

(In reply to comment #4)
> (In reply to comment #3)
> > My previous comment was incorrect.  The composite has to be persistently
> > started.  Simply having it resolved is not good enough.
> 
> My CompositeBundle reaches ACTIVE state prior to the restart. We appear to call
> start(Bundle.START_ACTIVATION_POLICY). Is this a persistent start?

I missed this comment.  Reopening bug to investigate.  Yes this should be persistent.  In my testing if the composite bundle was started after a restart then the composite framework got a valid context.
Comment 10 Thomas Watson CLA 2011-02-21 14:40:19 EST
(In reply to comment #9)
> > My CompositeBundle reaches ACTIVE state prior to the restart. We appear to call
> > start(Bundle.START_ACTIVATION_POLICY). Is this a persistent start?
> 
> I missed this comment.  Reopening bug to investigate.  Yes this should be
> persistent.  In my testing if the composite bundle was started after a restart
> then the composite framework got a valid context.

Is the start-level of your composite bundle higher than the bundle attempting to get the composite framework's bundle context?  If so that explains it because we currently only initialize the composite framework once the composite is activated.
Comment 11 Thomas Watson CLA 2011-02-21 15:52:35 EST
Created attachment 189443 [details]
patch

Alternate patch.  This patch moves the init of the composite to the getCompositeFramework().  This allows for some laziness but it still can be problematic if you get and hold onto the composite Framework object and the composite is persistently stopped.  In this case the Framework object will be stopped and is not re-initialized.
Comment 12 Thomas Watson CLA 2011-02-21 15:54:42 EST
I went ahead with the last patch.  Please test this out.  There are few left that I know are still using composites and testing is limited.