Pierre De Rop created FELIX-6889:
------------------------------------
Summary: An unknown filter index class breaks all DM components
with NPEs
Key: FELIX-6889
URL: https://issues.apache.org/jira/browse/FELIX-6889
Project: Felix
Issue Type: Bug
Components: Dependency Manager
Reporter: Pierre De Rop
Assignee: Pierre De Rop
When the {{org.apache.felix.dependencymanager.filterindex}} property references
a custom filter index class that can't be loaded (for example a typo in the
class name), DependencyManager starts without any visible failure, but all DM
components of all bundles are then broken.
What happens:
* the index creation fails with a {{ClassNotFoundException}}, which is only
printed on stdout ({{printStackTrace}});
* a {{null}} index is nevertheless added to the service registry cache index
list, and opening it fails with a {{NullPointerException}}, also only printed
on stdout;
* the indices declared after the invalid one are not created;
* the DM bundle is ACTIVE, but the service registry cache now contains a
{{null}} index.
>From then on, each service lookup or service listener registration done
>through the cache, as well as each service event received by the cache, fails
>with a {{NullPointerException}}. Service dependencies can't be tracked
>anymore, so no DM component can start. The NPE is raised far away from the
>real cause (the configuration error), which makes the problem hard to diagnose.
Also, if the index class fails with a {{LinkageError}} (such as
{{NoClassDefFoundError}} or {{ExceptionInInitializerError}}), the error is not
caught, and the DM bundle Activator fails to start.
h3. Example
{noformat}
org.apache.felix.dependencymanager.filterindex=no.such.IndexClass:some.definition;objectClass
{noformat}
At DM startup:
{noformat}
java.lang.ClassNotFoundException: no.such.IndexClass
java.lang.NullPointerException: Cannot invoke
"org.apache.felix.dm.FilterIndex.open(org.osgi.framework.BundleContext)"
because "index" is null
{noformat}
Then, for each service lookup or service event handled by the cache:
{noformat}
java.lang.NullPointerException: Cannot invoke
"org.apache.felix.dm.FilterIndex.isApplicable(String, String)" because
"filterIndex" is null
at
org.apache.felix.dm.impl.index.ServiceRegistryCache.hasFilterIndexFor(ServiceRegistryCache.java)
{noformat}
The {{objectClass}} index, declared after the invalid one, is never created.
h3. Expected behavior
* An index which can't be created is reported as an error through the DM
logger, with its definition and the cause.
* It does not leave the service registry cache in an inconsistent state: the
other configured indices are still created, and DM components keep working.
* The DM bundle Activator does not fail because of an invalid index.
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)