diff --git a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/support/SecurityIndexManager.java b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/support/SecurityIndexManager.java index a34f463a308de..96708a20bb76f 100644 --- a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/support/SecurityIndexManager.java +++ b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/support/SecurityIndexManager.java @@ -366,7 +366,8 @@ public void onStateRecovered(Consumer recoveredStateConsumer) { } /** - * Notifies listener once when the security index becomes available for search, or calls on failure on timeout. + * Waits up to {@code timeout} for the security index to become available for search, based on cluster state updates. + * Notifies {@code listener} once the security index is available for search, or calls {@code onFailure} on {@code timeout}. */ public void whenIndexAvailableForSearch(ActionListener listener, TimeValue timeout) { if (state.indexAvailableForSearch) { @@ -388,7 +389,7 @@ public void accept(SecurityIndexManager.State previousState, SecurityIndexManage } }; - // schedule cancellation on timeout -- keep reference to cancellable so a successful completion can cancel the timeout + // schedule failure handling on timeout -- keep reference to cancellable so a successful completion can cancel the timeout indexAvailableForSearchListener.cancellable = client.threadPool().schedule(() -> { removeStateListener(indexAvailableForSearchListener); notifyOnceListener.onFailure(