Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FELIX-6327 - NoSuchElementException when services are removed #47

Merged
merged 1 commit into from Sep 10, 2020

Conversation

tjwatson
Copy link
Member

The tryInvokeBind method needs more safeguards around when the reference
that just got bound is detected that it got removed.

The previous code always assumed there was at least one other viable
reference to bind to. That causes the NoSuchElementException when
trying to find a fallback reference. Fixing that exposed another issue
with the previous code where the state of the DependencyManager is not
properly restored in two aspects:

  1. Even when unbind is not invoked during tryInvokeBind the
    currentRefPair would get set to null when it must remain set to the
    previous value in cases where the invoke bind fails. A check is needed
    to be sure to only clear the currentRefPair if unbind was successfully
    invoked.

  2. After invoking bind/unbind there is a check to see if the reference
    is still viable (not deleted). This is where the reported problem
    occurs when there is no alternative reference available and a
    NoSuchElementException is thrown. Avoiding the NoSuchElementException
    and returning from tryInvokeBind would leave the DependencyManager in a
    state where it thinks there is still a binding thread doing work when
    that thread is really done. Additional checks are needed to ensure we
    always restore the binding thread state of the DepenencyManager on exit
    of tryInvokeBind method.

The tryInvokeBind method needs more safeguards around when the reference
that just got bound is detected that it got removed.

The previous code always assumed there was at least one other viable
reference to bind to.  That causes the NoSuchElementException when
trying to find a fallback reference.  Fixing that exposed another issue
with the previous code where the state of the DependencyManager is not
properly restored in two aspects:

1) Even when unbind is not invoked during tryInvokeBind the
currentRefPair would get set to null when it must remain set to the
previous value in cases where the invoke bind fails.  A check is needed
to be sure to only clear the currentRefPair if unbind was successfully
invoked.

2) After invoking bind/unbind there is a check to see if the reference
is still viable (not deleted).  This is where the reported problem
occurs when there is no alternative reference available and a
NoSuchElementException is thrown.  Avoiding the NoSuchElementException
and returning from tryInvokeBind would leave the DependencyManager in a
state where it thinks there is still a binding thread doing work when
that thread is really done.  Additional checks are needed to ensure we
always restore the binding thread state of the DepenencyManager on exit
of tryInvokeBind method.
@tjwatson tjwatson merged commit c3f6eba into apache:master Sep 10, 2020
@tjwatson tjwatson deleted the FELIX-6327 branch October 8, 2020 17:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant