Skip to content

FELIX-6884: Fix stale dependency events on service.ranking change - #604

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

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

Conversation

@pderop

@pderop pderop commented Nov 26, 2026

Copy link
Copy Markdown
Contributor

Motivation:

When a tracked service modifies its service.ranking, the event kept in the component's sorted set of dependency events changes its ordering key while it is stored in the set. The following remove() no longer finds it and add() inserts a duplicate. A stale entry can remain after all services are gone, so a required dependency stays available without any provider and the service is never released.

Modification:

ServiceEventImpl now orders on a snapshot of the service ranking and id instead of reading the live ServiceReference. On a modified event, ComponentImpl removes the event with its old key, refreshes the ranking, then adds it back. A unit test reproduces the scenario.

Result:

The dependency events stay consistent after a ranking change: a required dependency becomes unavailable once all its services are unregistered, and the services are released.

Motivation:

When a tracked service modifies its service.ranking, the event kept in the
component's sorted set of dependency events changes its ordering key while it
is stored in the set. The following remove() no longer finds it and add()
inserts a duplicate. A stale entry can remain after all services are gone, so
a required dependency stays available without any provider and the service
is never released.

Modification:

ServiceEventImpl now orders on a snapshot of the service ranking and id
instead of reading the live ServiceReference. On a modified event,
ComponentImpl removes the event with its old key, refreshes the ranking, then
adds it back. A unit test reproduces the scenario.

Result:

The dependency events stay consistent after a ranking change: a required
dependency becomes unavailable once all its services are unregistered, and
the services are released.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@pderop pderop self-assigned this Nov 26, 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