Uploaded image for project: 'Felix'
  1. Felix
  2. FELIX-5912

Handle empty package definitions in system package definitions more gracefully

    XMLWordPrintableJSON

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: framework-6.0.1
    • Fix Version/s: framework-6.0.2
    • Component/s: Framework
    • Labels:
      None

      Description

      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 == null) || (pkgextra.trim().length() == 0))
      ? syspkgs : syspkgs + (pkgextra.trim().startsWith(",") ? pkgextra : "," + 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:

      else if (pkgName.length() == 0)
      {
      throw new BundleException(
      "Exported package names cannot be zero length.");
      }

      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 == null) || (pkgextra.trim().length() == 0))
      ? syspkgs : syspkgs + (pkgextra.trim().startsWith(",") ? pkgextra : "," + pkgextra);
      if (syspkgs.startsWith(",")) syspkgs = syspkgs.substring(1);

      2.) log an error instead of throwing an exception in the ManifestParser normalizeExportClauses 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.

       

        Attachments

          Activity

            People

            • Assignee:
              karlpauls Karl Pauls
              Reporter:
              tom@phinneyridge.com Tom Rutchik
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Time Tracking

                Estimated:
                Original Estimate - 0.5h
                0.5h
                Remaining:
                Remaining Estimate - 0.5h
                0.5h
                Logged:
                Time Spent - Not Specified
                Not Specified