Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 349309 - Clean up code for initializing MRUBundleFileList
Summary: Clean up code for initializing MRUBundleFileList
Status: RESOLVED FIXED
Alias: None
Product: Equinox
Classification: Eclipse Project
Component: Framework (show other bugs)
Version: 3.7   Edit
Hardware: PC Mac OS X - Carbon (unsup.)
: P3 normal (vote)
Target Milestone: Juno M1   Edit
Assignee: Thomas Watson CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-06-14 08:32 EDT by Thomas Watson CLA
Modified: 2011-06-20 16:40 EDT (History)
2 users (show)

See Also:


Attachments
patch and updated tests (17.02 KB, patch)
2011-06-17 11:54 EDT, 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 Thomas Watson CLA 2011-06-14 08:32:08 EDT
Comments from Dani while reviewing bug 349105

The code could be improved for Juno: the life cycle of the MRU list is not well specified: it is created in the initializer which is not needed. I would either only create it in the getter or consider creating it in frameworkStart(). Maybe we could even remove the 'null' test in the getter and specify that 'null' will be returned if the bundle is not started. But I don't know the code well enough if it's safe to say that the getter must only be called on the started bundle.
Comment 1 Thomas Watson CLA 2011-06-14 12:53:41 EDT
(In reply to comment #0)
> Comments from Dani while reviewing bug 349105
> 
> The code could be improved for Juno: the life cycle of the MRU list is not well
> specified: it is created in the initializer which is not needed. I would either
> only create it in the getter or consider creating it in frameworkStart(). Maybe
> we could even remove the 'null' test in the getter and specify that 'null' will
> be returned if the bundle is not started. But I don't know the code well enough
> if it's safe to say that the getter must only be called on the started bundle.

Unfortunately we cannot do this in frameworkStart() since createBundleFile() is called before this method when reifying the bundles from a cached installation.  This happens long before activating the BundleContext for the framework.

I think the best we can do for now is to use your first suggestion and stop creating the object in the initializer.
Comment 2 Dani Megert CLA 2011-06-15 02:05:51 EDT
> Unfortunately we cannot do this in frameworkStart() since createBundleFile() is
> called before this method when reifying the bundles from a cached installation.
>  This happens long before activating the BundleContext for the framework.

And are we sure that it does not happen after the bundle got stopped? If not, clearing it on stop might be wrong too. Either a bundle should have no state, state while running or always - at least in an ideal world ;-).
Comment 3 Thomas Watson CLA 2011-06-17 11:54:50 EDT
Created attachment 198191 [details]
patch and updated tests

(In reply to comment #2)
> And are we sure that it does not happen after the bundle got stopped? If not,
> clearing it on stop might be wrong too. Either a bundle should have no state,
> state while running or always - at least in an ideal world ;-).

Unfortunately we are not dealing with a plain bundle here, instead it is the framework which still exists even after we have called out to the storage to shutdown.  I have decided to fix MRUBundleFileList to be able to reuse the same instance in cases where the storage is reused when the framework is relaunched.  This exposed some other issues with the storage manager that I have also fixed up to allow it to be reopened correctly.
Comment 4 Thomas Watson CLA 2011-06-17 11:58:28 EDT
One other comment on the tests.  I put a test "testMRUBundleFileListExpectedToFail" in there that I expect should fail on the Linux machine.  But this assumes the linux test machines have a ulimit that prevents 3000 files from being opened at the same time from a single process.
Comment 5 Thomas Watson CLA 2011-06-20 16:37:29 EDT
I released the patch but commented out the testMRUBundleFileListExpectedToFail method.  I need to do some additional testing on Linux to make sure this test will fail and to improve the tests.
Comment 6 Thomas Watson CLA 2011-06-20 16:40:13 EDT
I opened bug349871 to continue improving the tests on Linux.