FELIX-6845: Guard against null bundle in Log.serviceChanged()#521
Open
Apoorv-R98 wants to merge 1 commit into
Open
FELIX-6845: Guard against null bundle in Log.serviceChanged()#521Apoorv-R98 wants to merge 1 commit into
Apoorv-R98 wants to merge 1 commit into
Conversation
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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