Skip to content

FELIX-6845: Guard against null bundle in Log.serviceChanged()#521

Open
Apoorv-R98 wants to merge 1 commit into
apache:masterfrom
Apoorv-R98:FELIX-6845-fix-npe-in-log-servicechanged
Open

FELIX-6845: Guard against null bundle in Log.serviceChanged()#521
Apoorv-R98 wants to merge 1 commit into
apache:masterfrom
Apoorv-R98:FELIX-6845-fix-npe-in-log-servicechanged

Conversation

@Apoorv-R98

@Apoorv-R98 Apoorv-R98 commented Jun 23, 2026

Copy link
Copy Markdown

When a bundle is unregistered, ServiceReference.getBundle() may return null per the OSGi spec. Log.serviceChanged() does not guard against this, causing a NullPointerException when it attempts to call getSymbolicName() on the null bundle reference during a service unregistration race condition.

This PR adds a null check for the bundle and returns early if it is null, silently skipping the log entry for already-unregistered services.

https://issues.apache.org/jira/browse/FELIX-6845

…ent NPE during service unregistration race condition

When ServiceRegistration.setProperties() is called during bundle teardown,
Felix fires a ServiceEvent.MODIFIED to all ServiceListeners including Log.
At that point ServiceReference.getBundle() may return null per the OSGi spec
if the registering bundle has already been unregistered, causing an NPE in
Log.serviceChanged() when dereferencing the bundle for its symbolic name.

Fix: extract bundle reference and return early if null.
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.

2 participants