test_class.file: rxjava/src/test/java/io/reactivex/internal/operators/observable/ObservableReplayTest.java
test_class.identifier: ObservableReplayTest
test_case.body: @Test
      public void connectRace() {
          for (int i = 0; i < TestHelper.RACE_DEFAULT_LOOPS; i++) {
              final ConnectableObservable<Integer> co = Observable.range(1, 3).replay();
  
              Runnable r = new Runnable() {
                  @Override
                  public void run() {
                      co.connect();
                  }
              };
  
              TestHelper.race(r, r);
          }
      }
test_case.class_method_signature: ObservableReplayTest.connectRace()
test_case.full_signature: @Test public void connectRace()
test_case.identifier: connectRace
test_case.invocations: replay range connect race
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void connectRace()
focal_class.declarator: source
focal_class.modifier: final
focal_class.original_string: final ObservableSource<T> source;
focal_class.type: ObservableSource<T>
focal_class.var_name: source
focal_class.declarator: current
focal_class.modifier: final
focal_class.original_string: final AtomicReference<ReplayObserver<T>> current;
focal_class.type: AtomicReference<ReplayObserver<T>>
focal_class.var_name: current
focal_class.declarator: bufferFactory
focal_class.modifier: final
focal_class.original_string: final BufferSupplier<T> bufferFactory;
focal_class.type: BufferSupplier<T>
focal_class.var_name: bufferFactory
focal_class.declarator: onSubscribe
focal_class.modifier: final
focal_class.original_string: final ObservableSource<T> onSubscribe;
focal_class.type: ObservableSource<T>
focal_class.var_name: onSubscribe
focal_class.declarator: DEFAULT_UNBOUNDED_FACTORY = new UnBoundedFactory()
focal_class.modifier: @SuppressWarnings("rawtypes")
      static final
focal_class.original_string: @SuppressWarnings("rawtypes")
      static final BufferSupplier DEFAULT_UNBOUNDED_FACTORY = new UnBoundedFactory();
focal_class.type: BufferSupplier
focal_class.var_name: DEFAULT_UNBOUNDED_FACTORY
focal_class.file: rxjava/src/main/java/io/reactivex/internal/operators/observable/ObservableReplay.java
focal_class.identifier: ObservableReplay
focal_class.interfaces: implements HasUpstreamObservableSource<T>, Disposable
focal_class.class_method_signature: ObservableReplay.multicastSelector(
              final Callable<? extends ConnectableObservable<U>> connectableFactory,
              final Function<? super Observable<U>, ? extends ObservableSource<R>> selector)
focal_class.full_signature: public static Observable<R> multicastSelector(
              final Callable<? extends ConnectableObservable<U>> connectableFactory,
              final Function<? super Observable<U>, ? extends ObservableSource<R>> selector)
focal_class.identifier: multicastSelector
focal_class.modifiers: public static
focal_class.parameters: (
              final Callable<? extends ConnectableObservable<U>> connectableFactory,
              final Function<? super Observable<U>, ? extends ObservableSource<R>> selector)
focal_class.return: Observable<R>
focal_class.signature: Observable<R> multicastSelector(
              final Callable<? extends ConnectableObservable<U>> connectableFactory,
              final Function<? super Observable<U>, ? extends ObservableSource<R>> selector)
focal_class.class_method_signature: ObservableReplay.observeOn(final ConnectableObservable<T> co, final Scheduler scheduler)
focal_class.full_signature: public static ConnectableObservable<T> observeOn(final ConnectableObservable<T> co, final Scheduler scheduler)
focal_class.identifier: observeOn
focal_class.modifiers: public static
focal_class.parameters: (final ConnectableObservable<T> co, final Scheduler scheduler)
focal_class.return: ConnectableObservable<T>
focal_class.signature: ConnectableObservable<T> observeOn(final ConnectableObservable<T> co, final Scheduler scheduler)
focal_class.class_method_signature: ObservableReplay.createFrom(ObservableSource<? extends T> source)
focal_class.full_signature: @SuppressWarnings("unchecked") public static ConnectableObservable<T> createFrom(ObservableSource<? extends T> source)
focal_class.identifier: createFrom
focal_class.modifiers: @SuppressWarnings("unchecked") public static
focal_class.parameters: (ObservableSource<? extends T> source)
focal_class.return: ConnectableObservable<T>
focal_class.signature: ConnectableObservable<T> createFrom(ObservableSource<? extends T> source)
focal_class.class_method_signature: ObservableReplay.create(ObservableSource<T> source,
              final int bufferSize)
focal_class.full_signature: public static ConnectableObservable<T> create(ObservableSource<T> source,
              final int bufferSize)
focal_class.identifier: create
focal_class.modifiers: public static
focal_class.parameters: (ObservableSource<T> source,
              final int bufferSize)
focal_class.return: ConnectableObservable<T>
focal_class.signature: ConnectableObservable<T> create(ObservableSource<T> source,
              final int bufferSize)
focal_class.class_method_signature: ObservableReplay.create(ObservableSource<T> source,
              long maxAge, TimeUnit unit, Scheduler scheduler)
focal_class.full_signature: public static ConnectableObservable<T> create(ObservableSource<T> source,
              long maxAge, TimeUnit unit, Scheduler scheduler)
focal_class.identifier: create
focal_class.modifiers: public static
focal_class.parameters: (ObservableSource<T> source,
              long maxAge, TimeUnit unit, Scheduler scheduler)
focal_class.return: ConnectableObservable<T>
focal_class.signature: ConnectableObservable<T> create(ObservableSource<T> source,
              long maxAge, TimeUnit unit, Scheduler scheduler)
focal_class.class_method_signature: ObservableReplay.create(ObservableSource<T> source,
              final long maxAge, final TimeUnit unit, final Scheduler scheduler, final int bufferSize)
focal_class.full_signature: public static ConnectableObservable<T> create(ObservableSource<T> source,
              final long maxAge, final TimeUnit unit, final Scheduler scheduler, final int bufferSize)
focal_class.identifier: create
focal_class.modifiers: public static
focal_class.parameters: (ObservableSource<T> source,
              final long maxAge, final TimeUnit unit, final Scheduler scheduler, final int bufferSize)
focal_class.return: ConnectableObservable<T>
focal_class.signature: ConnectableObservable<T> create(ObservableSource<T> source,
              final long maxAge, final TimeUnit unit, final Scheduler scheduler, final int bufferSize)
focal_class.class_method_signature: ObservableReplay.create(ObservableSource<T> source,
              final BufferSupplier<T> bufferFactory)
focal_class.full_signature: static ConnectableObservable<T> create(ObservableSource<T> source,
              final BufferSupplier<T> bufferFactory)
focal_class.identifier: create
focal_class.modifiers: static
focal_class.parameters: (ObservableSource<T> source,
              final BufferSupplier<T> bufferFactory)
focal_class.return: ConnectableObservable<T>
focal_class.signature: ConnectableObservable<T> create(ObservableSource<T> source,
              final BufferSupplier<T> bufferFactory)
focal_class.class_method_signature: ObservableReplay.ObservableReplay(ObservableSource<T> onSubscribe, ObservableSource<T> source,
                               final AtomicReference<ReplayObserver<T>> current,
                               final BufferSupplier<T> bufferFactory)
focal_class.full_signature: private  ObservableReplay(ObservableSource<T> onSubscribe, ObservableSource<T> source,
                               final AtomicReference<ReplayObserver<T>> current,
                               final BufferSupplier<T> bufferFactory)
focal_class.identifier: ObservableReplay
focal_class.modifiers: private
focal_class.parameters: (ObservableSource<T> onSubscribe, ObservableSource<T> source,
                               final AtomicReference<ReplayObserver<T>> current,
                               final BufferSupplier<T> bufferFactory)
focal_class.signature:  ObservableReplay(ObservableSource<T> onSubscribe, ObservableSource<T> source,
                               final AtomicReference<ReplayObserver<T>> current,
                               final BufferSupplier<T> bufferFactory)
focal_class.class_method_signature: ObservableReplay.source()
focal_class.full_signature: @Override public ObservableSource<T> source()
focal_class.identifier: source
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: ObservableSource<T>
focal_class.signature: ObservableSource<T> source()
focal_class.class_method_signature: ObservableReplay.dispose()
focal_class.full_signature: @Override public void dispose()
focal_class.identifier: dispose
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void dispose()
focal_class.class_method_signature: ObservableReplay.isDisposed()
focal_class.full_signature: @Override public boolean isDisposed()
focal_class.identifier: isDisposed
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: boolean
focal_class.signature: boolean isDisposed()
focal_class.class_method_signature: ObservableReplay.subscribeActual(Observer<? super T> observer)
focal_class.full_signature: @Override protected void subscribeActual(Observer<? super T> observer)
focal_class.identifier: subscribeActual
focal_class.modifiers: @Override protected
focal_class.parameters: (Observer<? super T> observer)
focal_class.return: void
focal_class.signature: void subscribeActual(Observer<? super T> observer)
focal_class.class_method_signature: ObservableReplay.connect(Consumer<? super Disposable> connection)
focal_class.full_signature: @Override public void connect(Consumer<? super Disposable> connection)
focal_class.identifier: connect
focal_class.modifiers: @Override public
focal_class.parameters: (Consumer<? super Disposable> connection)
focal_class.return: void
focal_class.signature: void connect(Consumer<? super Disposable> connection)
focal_class.superclass: extends ConnectableObservable<T>
focal_method.body: @Override
      public void connect(Consumer<? super Disposable> connection) {
          boolean doConnect;
          ReplayObserver<T> ps;
          // we loop because concurrent connect/disconnect and termination may change the state
          for (;;) {
              // retrieve the current subscriber-to-source instance
              ps = current.get();
              // if there is none yet or the current has been disposed
              if (ps == null || ps.isDisposed()) {
                  // create a new subscriber-to-source
                  ReplayBuffer<T> buf = bufferFactory.call();
  
                  ReplayObserver<T> u = new ReplayObserver<T>(buf);
                  // try setting it as the current subscriber-to-source
                  if (!current.compareAndSet(ps, u)) {
                      // did not work, perhaps a new subscriber arrived
                      // and created a new subscriber-to-source as well, retry
                      continue;
                  }
                  ps = u;
              }
              // if connect() was called concurrently, only one of them should actually
              // connect to the source
              doConnect = !ps.shouldConnect.get() && ps.shouldConnect.compareAndSet(false, true);
              break; // NOPMD
          }
          /*
           * Notify the callback that we have a (new) connection which it can dispose
           * but since ps is unique to a connection, multiple calls to connect() will return the
           * same Disposable and even if there was a connect-disconnect-connect pair, the older
           * references won't disconnect the newer connection.
           * Synchronous source consumers have the opportunity to disconnect via dispose() on the
           * Disposable as subscribe() may never return in its own.
           *
           * Note however, that asynchronously disconnecting a running source might leave
           * child observers without any terminal event; ReplaySubject does not have this
           * issue because the dispose() call was always triggered by the child observers
           * themselves.
           */
  
          try {
              connection.accept(ps);
          } catch (Throwable ex) {
              if (doConnect) {
                  ps.shouldConnect.compareAndSet(true, false);
              }
              Exceptions.throwIfFatal(ex);
              throw ExceptionHelper.wrapOrThrow(ex);
          }
          if (doConnect) {
              source.subscribe(ps);
          }
      }
focal_method.class_method_signature: ObservableReplay.connect(Consumer<? super Disposable> connection)
focal_method.full_signature: @Override public void connect(Consumer<? super Disposable> connection)
focal_method.identifier: connect
focal_method.invocations: get isDisposed call compareAndSet get compareAndSet accept compareAndSet throwIfFatal wrapOrThrow subscribe
focal_method.modifiers: @Override public
focal_method.parameters: (Consumer<? super Disposable> connection)
focal_method.return: void
focal_method.signature: void connect(Consumer<? super Disposable> connection)