Skip to content

FELIX-6890: Fix NPE in getServiceReferences(Class, String) - #610

Open
pderop wants to merge 1 commit into
apache:masterfrom
pderop:FELIX-6890
Open

pderop wants to merge 1 commit into
apache:masterfrom
pderop:FELIX-6890

Conversation

@pderop

@pderop pderop commented Nov 27, 2026

Copy link
Copy Markdown
Contributor

Motivation:

When the service registry cache is enabled, the BundleContext injected into DM components is a BundleContextInterceptor. Its getServiceReferences(Class, String) method threw a NullPointerException when no service matched, instead of returning an empty collection as required by the OSGi specification.

Modification:

Return an empty collection when no service matches. Add a unit test covering both the indexed and the non-indexed lookups.

Result:

getServiceReferences(Class, String) behaves the same whether the service registry cache is enabled or not.

Motivation:

When the service registry cache is enabled, the BundleContext injected
into DM components is a BundleContextInterceptor. Its
getServiceReferences(Class, String) method threw a NullPointerException
when no service matched, instead of returning an empty collection as
required by the OSGi specification.

Modification:

Return an empty collection when no service matches. Add a unit test
covering both the indexed and the non-indexed lookups.

Result:

getServiceReferences(Class, String) behaves the same whether the service
registry cache is enabled or not.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@pderop pderop self-assigned this Nov 27, 2026
@pderop pderop changed the title FELIX-6890: DM: fix NPE in getServiceReferences(Class, String) FELIX-6890: Fix NPE in getServiceReferences(Class, String) Nov 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant