private void maybeSetDataSourceWithResult(DataSource<T> dataSource, boolean isFinished) {
      DataSource<T> oldDataSource = null;
      synchronized (FirstAvailableDataSource.this) {
        if (dataSource != mCurrentDataSource || dataSource == mDataSourceWithResult) {
          return;
        }
        // If we didn't have any result so far, we got one now, so we'll set
        // {@code mDataSourceWithResult} to point to the current data source.
        // If we did have a result which came from another data source,
        // we'll only set {@code mDataSourceWithResult} to point to the current
        // data source if it has finished (i.e. the new result is final).
        if (mDataSourceWithResult == null || isFinished) {
          oldDataSource = mDataSourceWithResult;
          mDataSourceWithResult = dataSource;
        }
      }
      closeSafely(oldDataSource);
    }
{@link DataSource} supplier that provides a data source which will forward results of the first
available data source.

<p>Data sources are obtained in order. Only if the current data source fails, or if it finishes
without result, the next one will be tried.
fbcore/src/main/java/com/facebook/datasource/FirstAvailableDataSourceSupplier.java