Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 337819 - Equinox DS fails on directives/properties in Service-Component manifest header
Summary: Equinox DS fails on directives/properties in Service-Component manifest header
Status: RESOLVED FIXED
Alias: None
Product: Equinox
Classification: Eclipse Project
Component: Compendium (show other bugs)
Version: unspecified   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: 3.7 M6   Edit
Assignee: Stoyan Boshev CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-02-22 07:32 EST by Simon Chemouil CLA
Modified: 2011-02-24 05:01 EST (History)
1 user (show)

See Also:
s.boshev: review+


Attachments
Proposed fix (1.98 KB, patch)
2011-02-22 07:37 EST, Simon Chemouil CLA
no flags Details | Diff
proposed fix for header syntax (2.97 KB, patch)
2011-02-22 08:59 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 Simon Chemouil CLA 2011-02-22 07:32:51 EST
Hello,

As per Declarative Service's spec (compendium 112.4), a DS implementation should ignore directives and properties in the Service-Component header.

As such, an header such as:

------------ >8------------
Service-Component: OSGI-INF/component1.xml;foo:=bar,OSGI-INF/component2.xml;bar
------------ >8------------

should properly find components from definitions located at OSGI-INF/component1.xml and OSGI-INF/component2.xml

However, the current Equinox DS implementation fails on this and looks for files named OSGI-INF/component1.xml;foo:=bar and OSGI-INF/component2.xml;bar


I ran across this problem because of a bug in maven-bundle-plugin *but* this is also looks like a bug in Equinox DS (it is also BJ Hargrave's interpretation, see http://groups.google.com/group/bndtools-users/msg/e87b9869f449cd14 )
Comment 1 Simon Chemouil CLA 2011-02-22 07:37:26 EST
Created attachment 189478 [details]
Proposed fix

Here's a tentative fix that should be API compatible with the execution environment already set for Equinox DS. 

I'm using it with no problems, whether manifest have directives/properties or not.

It strips the useless parts of the headers, and returns them to the original code expecting them not to have directives. (It might be more efficient to rewrite the parsing routing completely, but I went for a solution that involved no rewrite of existing code to be safe).
Comment 2 Thomas Watson CLA 2011-02-22 08:59:27 EST
Created attachment 189486 [details]
proposed fix for header syntax

From spec:

Service-Component ::= header
header ::= clause ( ’,’ clause ) * 
clause ::= path ( ’;’ path ) * ( ’;’ parameter ) *

The current code and the supplied patch do not handle 'clause' where there are ';' separated paths: e.g. 

Service-Component: OSGI-INF/one.xml; OSGI-INF/two.xml; attr=test; directive:=test

This patch uses ManifestElement (the parser supplied by org.eclipse.osgi).  DS is already importing the org.eclipse.osgi.util package for the NLS class.  You might as well use the ManifestElement class to do this parsing.  There are lots of gotchas to parsing this common header syntax.  For example, the current code does not handle quoted strings either in the path elements.
Comment 3 Thomas Watson CLA 2011-02-22 09:04:38 EST
Stoyan, please review the patch and release if appropriate.  Thanks.
Comment 4 Simon Chemouil CLA 2011-02-22 09:07:10 EST
(In reply to comment #2)
> Created attachment 189486 [details]
> proposed fix for header syntax
[snip]

Thomas,

Thanks for the comments & the patch. Indeed, I was pretty sure there was some class doing appropriate Manifest parsing in Equinox, but I didn't look for it. I also didn't see paths could be separated by semi-colons.

Your solution is much better :-). Thanks again!
Comment 5 Simon Chemouil CLA 2011-02-22 09:07:55 EST
Comment on attachment 189478 [details]
Proposed fix

See Thomas Watson's patch.
Comment 6 Stoyan Boshev CLA 2011-02-24 05:01:06 EST
Thanks for the patch Thomas!
I have released it in HEAD.