You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@felix.apache.org by "Tom Rutchik (JIRA)" <ji...@apache.org> on 2018/08/31 00:44:00 UTC
[jira] [Commented] (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=16598082#comment-16598082 ]
Tom Rutchik commented on FELIX-5912:
------------------------------------
Karl,
Thanks
If you're interested here's the kind of code that produces an empty syspkgs:
public void initializeFramework() {
Thread t = new Thread(new Runnable() {
@Override
public void run() {
Map<String, Object> config = new HashMap<String, Object>();
config.put("osgi.signature.support.verify", "false"); // signed jar checking disabled for development
config.put("osgi.compatibility.bootdelegation", "true");
config.put("osgi.framework.bootdelegation", "true");
config.put("osgi.framework.useSystemProperties", "true");
config.put("osgi.console.enable.builtin", "true");
config.put("osgi.configuration.area.default", getLocationUrl("config"));
config.put("osgi.configuration.area", getLocationUrl("config"));
config.put("java.specification.version", "1.8");
config.put(Constants.FRAMEWORK_BUNDLE_PARENT, Constants.FRAMEWORK_BUNDLE_PARENT_APP);
//config.put(Constants.FRAMEWORK_EXECUTIONENVIRONMENT,"JavaSE-1.8");
//this makes the bundle use the dalvik class loader
/* see BundleWiringImpl.determineParentClassLoader() to better understand how it affects the implementation. */
config.put(Constants.FRAMEWORK_STORAGE, getLocationUrl("framework"));
config.put(Constants.FRAMEWORK_SYSTEMPACKAGES_EXTRA, ANDROID_FRAMEWORK_PACKAGES + "," + JAVA_EXTRA_PACKAGES + "," + BIMTABELLAE_EXTRA_PACKAGES + ","+ OSGI_EXTRA_PACKAGES + "," + GOOGLE_EXTRA_PACKAGES);
config.put(Constants.FRAMEWORK_SYSTEMCAPABILITIES, FRAMEWORK_ENVIRONMENT_CAPABILITIES);
config.put(Constants.FRAMEWORK_SYSTEMCAPABILITIES_EXTRA, FRAMEWORK_ENVIRONMENT_EXTRA_CAPABILITIES);
//config.put(Constants.PROVIDE_CAPABILITY, BIMTABELLAE_CORE_CAPABILITIES);
List<Object> list = new LinkedList<Object>();
//list.add(activator);
config.put(FelixConstants.SYSTEMBUNDLE_ACTIVATORS_PROP, list);
config.put("felix.cache.locking", "false");
m_fwk = new FrameworkFactory().newFramework(config);
Sys.log.i(Sys.application.getContext().getString(R.string.infoInitializingOsgi));
try {
m_fwk.init();
} catch (BundleException e) {
...
I think it's because I build the configuration and rather than putting it in an osgi configuration file, which I will eventually do.
-Tom Rutchik
> 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
> Fix For: framework-6.0.2
>
> 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)