Tom Rutchik created FELIX-5912:
----------------------------------

             Summary: Felix init error
                 Key: FELIX-5912
                 URL: https://issues.apache.org/jira/browse/FELIX-5912
             Project: Felix
          Issue Type: Bug
          Components: Framework
    Affects Versions: framework-6.0.1
            Reporter: Tom Rutchik


A felix initiation error can occur if one adds extra 
"org.osgi.framework.system.package.extras".

The error produced is caused by a empty package name.

The problem occurs in the class ExtensionManager in the update(Map configMap) 
method.

It contains the following line:

syspkgs = ((pkgextra == {color:#000080}null{color}) || 
(pkgextra.trim().length() == {color:#0000ff}0{color}))
 ? syspkgs : syspkgs + (pkgextra.trim().startsWith({color:#008000}","{color}) ? 
pkgextra : {color:#008000}"," {color}+ pkgextra);

When syspkgs has the value "" (the empty string) the result is ",pkgextra".  
Syspkgs then gets stored in m_headerMap.  When that header gets parsed later 
that comma at the beginning of the string gets interpreted as a blank package 
name and the class ManifestParser method normalizeExportClauses Method throws 
an exception:

{color:#000080}else if {color}(pkgName.length() == {color:#0000ff}0{color})
{
 {color:#000080}throw new {color}BundleException(
 {color:#008000}"Exported package names cannot be zero length."{color});
}

The result is that the remaining extra packages are not exported.  Other 
bundles that need these extra packages of course will not be resolved as a 
result of this exception, and its easy to miss the fact that the exception was 
thrown during initialization .

There are two easy solutions to the problem:

1.) in the ExtensionManager update manager make the following change (add one 
line of code):

syspkgs = ((pkgextra == {color:#000080}null{color}) || 
(pkgextra.trim().length() == {color:#0000ff}0{color}))
 ? syspkgs : syspkgs + (pkgextra.trim().startsWith({color:#008000}","{color}) ? 
pkgextra : {color:#008000}"," {color}+ pkgextra);
{color:#000080}if {color}(syspkgs.startsWith({color:#008000}","{color})) 
syspkgs = syspkgs.substring({color:#0000ff}1{color});

2.) log an error instead of throwing an exception in the ManifestParser 
{color:#333333}normalizeExportClauses {color}method and just ignore the blank 
package name, since it doesn't really cause a problem.

I've test solution 1 and it solves the problem, but solution 2 is probably a 
more robust and forgiving solution. 

Note: this problem doesn't occur if syspkgs is not the empty string. So the 
problem only occurs under certain configurations.

 



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to