--- old/src/share/classes/java/util/stream/ReduceOps.java 2013-07-05 16:28:06.654022170 -0700 +++ new/src/share/classes/java/util/stream/ReduceOps.java 2013-07-05 16:28:03.014022235 -0700 @@ -148,17 +148,18 @@ * reference values. * * @param the type of the input elements - * @param the type of the result + * @param the type of the intermediate reduction result + * @param the type of the final reduction result * @param collector a {@code Collector} defining the reduction * @return a {@code ReduceOp} implementing the reduction */ - public static TerminalOp - makeRef(Collector collector) { - Supplier supplier = Objects.requireNonNull(collector).resultSupplier(); - BiFunction accumulator = collector.accumulator(); - BinaryOperator combiner = collector.combiner(); - class ReducingSink extends Box - implements AccumulatingSink { + public static TerminalOp + makeRef(Collector collector) { + Supplier supplier = Objects.requireNonNull(collector).supplier(); + BiConsumer accumulator = collector.accumulator(); + BinaryOperator combiner = collector.combiner(); + class ReducingSink extends Box + implements AccumulatingSink { @Override public void begin(long size) { state = supplier.get(); @@ -166,9 +167,7 @@ @Override public void accept(T t) { - R newResult = accumulator.apply(state, t); - if (state != newResult) - state = newResult; + accumulator.accept(state, t); } @Override @@ -176,7 +175,7 @@ state = combiner.apply(state, other.state); } } - return new ReduceOp(StreamShape.REFERENCE) { + return new ReduceOp(StreamShape.REFERENCE) { @Override public ReducingSink makeSink() { return new ReducingSink();