Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 367614

Summary: SecurityAdmin allows duplicate ConditionalPermissionInfo's
Product: [Eclipse Project] Equinox Reporter: Missing name Mising name <Rene.Brandstetter>
Component: FrameworkAssignee: Thomas Watson <tjwatson>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: remy.suen, Rene.Brandstetter, tjwatson
Version: 3.7.1   
Target Milestone: Juno M5   
Hardware: PC   
OS: Windows 7   
Whiteboard:

Description Missing name Mising name CLA 2011-12-29 05:56:49 EST
Build Identifier: Version: Indigo Service Release 1 Build id: 20110916-0149

If you have a closer look into the method "boolean org.eclipse.osgi.internal.permadmin.SecurityAdmin#commit(List<ConditionalPermissionInfo> rows, long updateStamp)" you will see that the IllegalStateException for duplicate named ConditionalPermissionInfos will never be thrown. Because the "names" collection is created in this method and nobody adds names to it.

This leads to an unrecognized growing of the .permdata file with duplicate entries.

Reproducible: Always

Steps to Reproduce:
1. Create a Securtiy Bundle which adds some ConditionalPermissionInfos to the SecurityTable via the ConditionalPermissionAdmin. (don't forget to add the AllPermission to your Security Bundle)
2. start an OSGi console which contains your security bundle (it should add the permissions now)
3. on the first start the .permdata file will be created and will contain only the ConditionalPermissionInfos you made
4. close your OSGi console
5. start the OSGi console containing your security bundle once again (do not clear the configuration area before launching)
6. If your security bundle now adds it's permission you will not get an IllegalStateException( "Duplicate name ...." ). But it should because you get the previous ConditionalPermissionInfos from the .permdata file and add them once again with your Security Bundle.

--> this leads to an unrecognized growing of the .permdata file every time your bundle adds its ConditionalPermissionInfos
Comment 1 Thomas Watson CLA 2012-01-03 10:04:46 EST
Need to add a testcase.  The OSGi Compliance Tests must not have any tests for this either.  Sigh.

Thanks for the analysis and bug report.
Comment 2 Thomas Watson CLA 2012-01-03 10:37:20 EST
Test and fix committed to master with:

http://git.eclipse.org/c/equinox/rt.equinox.framework.git/commit/?id=179cd3fe810fd5ad086c82c4d8fd5cc61c09e1e3