You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@felix.apache.org by "Karl Pauls (JIRA)" <ji...@apache.org> on 2018/08/22 09:55:00 UTC

[jira] [Comment Edited] (FELIX-5912) Handle empty package definitions in system package definitions more gracefully

    [ https://issues.apache.org/jira/browse/FELIX-5912?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16588636#comment-16588636 ] 

Karl Pauls edited comment on FELIX-5912 at 8/22/18 9:54 AM:
------------------------------------------------------------

[~tom@phinneyridge.com], I'm not sure why this would be happening. Why are the syspkgs empty in the first place?

That said, we had people run into empty package definitions in syspkgs or syspkg.extra and it seems like your 2. proposal (log an error but just skip the empty package) would nicer. 

Changing this into an improvement until I understand what causes the empty syspkgs.


was (Author: karlpauls):
[~tom@phinneyridge.com], I'm not sure why this would be happening. Why are the syspkgs empty in the first place?

> Handle empty package definitions in system package definitions more gracefully
> ------------------------------------------------------------------------------
>
>                 Key: FELIX-5912
>                 URL: https://issues.apache.org/jira/browse/FELIX-5912
>             Project: Felix
>          Issue Type: Improvement
>          Components: Framework
>    Affects Versions: framework-6.0.1
>            Reporter: Tom Rutchik
>            Assignee: Karl Pauls
>            Priority: Minor
>   Original Estimate: 0.5h
>  Remaining Estimate: 0.5h
>
> 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)