Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 253942 - MRUBundleFileList causes IllegalStateException when restarting Equinox instance
Summary: MRUBundleFileList causes IllegalStateException when restarting Equinox instance
Status: RESOLVED FIXED
Alias: None
Product: Equinox
Classification: Eclipse Project
Component: Framework (show other bugs)
Version: 3.5   Edit
Hardware: PC All
: P3 normal (vote)
Target Milestone: 3.5 M4   Edit
Assignee: Thomas Watson CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-11-05 10:39 EST by Rob Harrop CLA
Modified: 2008-11-07 04:40 EST (History)
1 user (show)

See Also:


Attachments
repo case (5.82 KB, application/zip)
2008-11-05 10:40 EST, Rob Harrop CLA
no flags Details
proposed patch (6.99 KB, patch)
2008-11-06 07:12 EST, Rob Harrop CLA
tjwatson: iplog+
Details | Diff
update patch (14.07 KB, patch)
2008-11-06 14:05 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 Rob Harrop CLA 2008-11-05 10:39:29 EST
Build ID: 3.5

Steps To Reproduce:
1. See attached repo case.


More information:
When querying a bundle for resources after restarting an Equinox instance the MRUBundleFileList causes an ISE when accessing its EventManager which was closed when the framework was previously shutdown and then was never reopened.

Enough bundles need to be opened for the MRU cache to run out of space before the problem shows.

A workaround is to disable the MRU cache. A better solution is not to use a static for the MRUBundleFileList, or at least to reopen this static when the framework is started again. This also means that an EventManager needs to be restartable.

Tom - I'm happy to patch this up if you have a solution that you prefer.
Comment 1 Rob Harrop CLA 2008-11-05 10:40:00 EST
Created attachment 117107 [details]
repo case
Comment 2 Thomas Watson CLA 2008-11-05 13:52:34 EST
(In reply to comment #0)
> Tom - I'm happy to patch this up if you have a solution that you prefer.
> 

Sure, you can have this one Rob!!

I prefer the approach to get rid of the static mruList in ZipBundleFile.  I think the mruList could become a final instance variable assigned from the constructor.  This way BaseStorage could create a single MRUBundleFileList for all ZipBundleFile objects it creates.  You will likely want to replace all direct accesses to the mruList with methods to do null checks when the old ZipBundleFile constructor is used or null is passed into the ZipBundleFile constructor.

Notice that SignedBundleHook also creates ZipBundleFile objects.  I think it is fine to us a null mruList here (basically disabled) because this code path should not keep the ZipBundleFile open for long periods of time.  It reads the content and caches results and then closes the bundle file.
Comment 3 Rob Harrop CLA 2008-11-06 07:12:06 EST
Created attachment 117184 [details]
proposed patch
Comment 4 Thomas Watson CLA 2008-11-06 14:05:45 EST
Created attachment 117234 [details]
update patch

Thanks Rob!  That is what I was thinking.  I have updated your patch with the following:

- updated copyrights to include you
- Changed ZipBundleEntry to use final fields and use a ZipBundleFile instead of plain BundleFile to avoid unnecessary casts.
- moved shutdown of mruList to BaseStorage.frameworkStop(BundleContext) so the mruList can be a private field.

I have also added a testcase to org.eclipse.osgi.tests.
Comment 5 Thomas Watson CLA 2008-11-06 15:38:55 EST
I released the fix and testcase.
Comment 6 Thomas Watson CLA 2008-11-06 15:39:33 EST
Comment on attachment 117184 [details]
proposed patch

Marking for the IP log.  Thanks again Rob.
Comment 7 Rob Harrop CLA 2008-11-07 04:40:51 EST
Thanks Tom - that's great