code: private void waitForReplacementBackend() {
        int waitedMilliseconds = 0;
        try {
           while (replacement != null) {
              if (waitedMilliseconds >= GRACE_MILLISECONDS_FOR_REPLACEMENT) {
                 return;
              }
              Thread.sleep(POLLING_MILLISECONDS_FOR_REPLACEMENT);
              waitedMilliseconds += POLLING_MILLISECONDS_FOR_REPLACEMENT;
           }
        } catch (InterruptedException e) {
           Thread.currentThread().interrupt();
        }
     }
docs: If some error happened, and a new IndexingBackend was provided, it is safe to
  assume the error relates with the fact the current backend is no longer valid.
  At this point we can still forward the work from the current stack to the next
  backend, creating a linked list of forwards to the right backend: