code: @Override
      public <R, A> R collect(Collector<? super T, A, R> collector) {
          Predicate<A> finished = finished(collector);
          if (finished != null) {
              BiConsumer<A, ? super T> acc = collector.accumulator();
              BinaryOperator<A> combiner = collector.combiner();
              Spliterator<T> spliterator = spliterator();
              if (!isParallel()) {
                  A a = collector.supplier().get();
                  if (!finished.test(a)) {
                      try {
                          // forEachRemaining can be much faster
                          // and take much less memory than tryAdvance for certain
                          // spliterators
                          spliterator.forEachRemaining(e -> {
                              acc.accept(a, e);
                              if (finished.test(a))
                                  throw new CancelException();
                          });
                      } catch (CancelException ex) {
                          // ignore
                      }
                  }
                  return collector.finisher().apply(a);
              }
              Spliterator<A> spltr;
              if (!spliterator.hasCharacteristics(Spliterator.ORDERED)
                  || collector.characteristics().contains(Characteristics.UNORDERED)) {
                  spltr = new UnorderedCancellableSpliterator<>(spliterator, collector.supplier(), acc, combiner,
                          finished);
              } else {
                  spltr = new OrderedCancellableSpliterator<>(spliterator, collector.supplier(), acc, combiner, finished);
              }
              return collector.finisher().apply(
                  new StreamEx<>(StreamSupport.stream(spltr, true), context).findFirst().get());
          }
          return rawCollect(collector);
      }
docs: {@inheritDoc}
  
  <p>
  If special <a
  href="package-summary.html#ShortCircuitReduction">short-circuiting
  collector</a> is passed, this operation becomes short-circuiting as well.