Browse Source
When an infinite Stream was handed into StreamUtils.zip(…) as first argument, the resulting stream was infinite, too, while inverting the argument order was limiting the resulting stream to the length of the finite one. This is now fixed by actually evaluating whether we can advance on both of the streams and shortcutting the process if that is not possible on either of the streams, limiting the processing of the overall Stream to the shorter of the two as already advertised in the Javadoc. Fixes #2426.2.4.x
3 changed files with 62 additions and 2 deletions
@ -0,0 +1,34 @@
@@ -0,0 +1,34 @@
|
||||
package org.springframework.data.util; |
||||
|
||||
import java.util.function.Consumer; |
||||
|
||||
import org.springframework.lang.Nullable; |
||||
|
||||
/** |
||||
* A simple {@link Consumer} that captures the instance handed into it. |
||||
* |
||||
* @author Oliver Drotbohm |
||||
* @since 2.4.12 |
||||
*/ |
||||
class Sink<T> implements Consumer<T> { |
||||
|
||||
private T value; |
||||
|
||||
/** |
||||
* Returns the value captured. |
||||
* |
||||
* @return |
||||
*/ |
||||
public T getValue() { |
||||
return value; |
||||
} |
||||
|
||||
/* |
||||
* (non-Javadoc) |
||||
* @see java.util.function.Consumer#accept(java.lang.Object) |
||||
*/ |
||||
@Override |
||||
public void accept(@Nullable T t) { |
||||
this.value = t; |
||||
} |
||||
} |
||||
Loading…
Reference in new issue