Bug 206765 - PDE shoud ignore non-osgi Manifests in workspace projects
Summary: PDE shoud ignore non-osgi Manifests in workspace projects
Status: RESOLVED FIXED
Alias: None
Product: PDE
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.4   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.4 M3   Edit
Assignee: Brian Bauman CLA
QA Contact:
URL:
Whiteboard:
Keywords: performance
Depends on:
Blocks:
 
Reported: 2007-10-18 10:38 EDT by Brian Bauman CLA
Modified: 2007-10-26 00:29 EDT (History)
5 users (show)

See Also:


Attachments
[sample MANIFEST.MF] (127 bytes, application/octet-stream)
2007-10-18 15:22 EDT, Eric Jodet CLA
no flags Details
proposed fix (2.57 KB, text/plain)
2007-10-24 15:04 EDT, Brian Bauman CLA
no flags Details
revised fix (3.63 KB, patch)
2007-10-25 17:39 EDT, Brian Bauman CLA
no flags Details | Diff
patch for 3.3 maintenance release stream (3.63 KB, patch)
2007-10-25 18:07 EDT, Brian Bauman CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Brian Bauman CLA 2007-10-18 10:38:15 EDT
PDE currently assumes all META-INF/MANIFEST.MF files in the root of a project are OSGi manifests.  There are scenarios in some products which a non-plug-in project has a Manifest file.  

When saving the cache of the workspace state, PDE currently assumes that if a Manifest file does not have an Bundle-SymbolicName that something is wrong and does not save the cache.  We need to be more flexible and save caches when the user has non-OSGi Manifests in their workspace.
Comment 1 Eric Jodet CLA 2007-10-18 15:21:03 EDT
Discovered while testing fix for bug 206382.

Found that some projects with a MANIFEST.MF and no plugin.xml file where loaded at startup @see PluginModelManager#addToTable(IPluginModelBase[])
and line: if (id == null)
		continue;

we do not skip such projects, and these are loaded with other models.

When shutting down, PDEState#shouldSaveState(IPluginModelBase[]) will return false if a single of the workspace projects has either:
- id set to null
- no bundle description

As a consequence, if a workspace contains a single of such projects, then we won't be able to save and cache the workspace projects.
Which in turn has a severe impact on startup when dealing with large workspace.

I'll attach a sample MANIFEST.MF file.
Comment 2 Eric Jodet CLA 2007-10-18 15:22:07 EDT
Created attachment 80691 [details]
[sample MANIFEST.MF]
Comment 3 Philipe Mulet CLA 2007-10-19 05:41:27 EDT
Added performance keyword, due to startup time implications when unable to reload cached data.
Comment 4 Brian Bauman CLA 2007-10-24 15:04:49 EDT
Created attachment 81091 [details]
proposed fix

This patch should fix the problem.  If a model in the workspace does not have an id, then we can assume it is not an OSGi project.
Comment 5 Eric Jodet CLA 2007-10-24 16:25:39 EDT
(In reply to comment #4)
according to the Sun spec, as referenced in OSGI 4.1 spec, the only mandatory attribute for an OSGI manifest is the name (Constants.BUNDLE_NAME / Bundle-Name).
The Bundle-SymbolicName or Bundle description do not look mandatory (but ain't not expert).
The fact is that I have many workspaces where I have bundles that have a MANIFEST.MF with:
- Manifest version, Name, id and so on
- Manifest version and classpath attributes

see: http://java.sun.com/j2se/1.4.2/docs/guide/jar/jar.html#Manifest%20Specification

Ideal situation would be to be able to load (at startup) and save (at shutdown) both osgi and non-osgi bundles.
Comment 6 Brian Bauman CLA 2007-10-24 17:39:35 EDT
I am not sure all the required OSGi headers, but I know Bundle-SymbolicName is definitely required.  This is the unique identifier for each bundle.  The idea is that if the Manifest does not have a Bundle-SymbolicName, it is not trying to be an OSGi Bundle.  Therefore, PDE tooling will ignore it (since it can't do much with it).  When saving our cache, we will exclude it from the cache.

One problem I just found was that when we read the cache, we don't create a model for the projects which don't have OSGi manifests.  I imagine this should not be a problem, but it is not wise to return a different value compared to what you would see after a restart.  I will have to look into this a bit more to make sure we don't break anything.
Comment 7 Brian Bauman CLA 2007-10-25 17:39:51 EDT
Created attachment 81206 [details]
revised fix

Updated the fix to return consistent information after restart.  If a project has a Manifest file but is not an OSGi file, PDE will still create a model for it in the WorkspacePluginModelManager.

Upon shutdown, we use the locations of all the models to calculate the hash for the directory.  We then only save the information from the bundles which have BundleDescriptions (OSGi bundles).  

Upon startup, we calculate the hash from all the project's that contain Manifest files so we can accurately calculate the hash for the directory where we saved the cache.  When we find it, we read in and create all the valid models we saved.  Upon initialization of the WorkspacePluginModelManager, we include the cached models, but also create a model for any project with a Manifest for which we were not able to create a model from the cache.  By doing this, when we shut down we calculate the same cache directory if nothing changes, and guarantee the same result for PluginRegistry.findModel(IProject) for a project that is not an OSGi project.
Comment 8 Brian Bauman CLA 2007-10-25 18:07:31 EDT
Created attachment 81209 [details]
patch for 3.3 maintenance release stream

Same patch as above, just targeted for 3.3.
Comment 9 Brian Bauman CLA 2007-10-25 18:11:21 EDT
For right now, I am only applying the fix to HEAD.  I attached a patch for safe keeping in case people need it in 3.3.2.  If that is the case, we can reopen the bug and apply the patch.
Comment 10 Eric Jodet CLA 2007-10-26 00:29:25 EDT
(In reply to comment #7)
that sounds a smarter way to save workspace projects.
I'll have a go and will try this fix ASAP.