mirror of
https://github.com/elastic/elasticsearch.git
synced 2025-06-28 17:34:17 -04:00
Properly remove security index recovered state consumer (#112927)
One of the security index state change listeners attempts to remove itself once it has received the expected event. However, since the consumer is a lambda, `this` in `stateChangeListeners.remove(this);` actually refers to the enclosing class instance (`SecurityIndexManager.this`) which results in a noop and not an actual removal of the relevant consumer. This PR fixes this by converting the lambda to an anonymous class. It's technically a bug, but so minor that it doesn't warrant a bug changelog IMO; so I'm labelling it a non-issue instead.
This commit is contained in:
parent
ef154612b7
commit
cfe8dfa322
1 changed files with 10 additions and 7 deletions
|
@ -344,7 +344,9 @@ public class SecurityIndexManager implements ClusterStateListener {
|
|||
}
|
||||
|
||||
public void onStateRecovered(Consumer<State> recoveredStateConsumer) {
|
||||
BiConsumer<State, State> stateChangeListener = (previousState, nextState) -> {
|
||||
BiConsumer<State, State> stateChangeListener = new BiConsumer<>() {
|
||||
@Override
|
||||
public void accept(State previousState, State nextState) {
|
||||
boolean stateJustRecovered = previousState == UNRECOVERED_STATE && nextState != UNRECOVERED_STATE;
|
||||
boolean stateAlreadyRecovered = previousState != UNRECOVERED_STATE;
|
||||
if (stateJustRecovered) {
|
||||
|
@ -352,6 +354,7 @@ public class SecurityIndexManager implements ClusterStateListener {
|
|||
} else if (stateAlreadyRecovered) {
|
||||
stateChangeListeners.remove(this);
|
||||
}
|
||||
}
|
||||
};
|
||||
stateChangeListeners.add(stateChangeListener);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue