Rename InputStreamSubscriber to SubscriberInputStream
It is both, but InputStream is what's exposed for public use, in effect an InputStream backed by a Subscriber source. See gh-31677
This commit is contained in:
@@ -472,16 +472,16 @@ public abstract class DataBufferUtils {
|
||||
* Note: {@link Subscription#request(long)} happens eagerly for the first time upon subscription
|
||||
* and then repeats every time {@code bufferSize - (bufferSize >> 2)} consumed.
|
||||
* @param publisher the source of {@link DataBuffer} which should be represented as an {@link InputStream}
|
||||
* @param bufferSize the maximum amount of {@link DataBuffer} prefetched in advance and stored inside {@link InputStream}
|
||||
* @param demand the maximum number of buffers to request from the Publisher and buffer on an ongoing basis
|
||||
* @return an {@link InputStream} instance representing given {@link Publisher} messages
|
||||
*/
|
||||
public static <T extends DataBuffer> InputStream subscribeAsInputStream(Publisher<T> publisher, int bufferSize) {
|
||||
public static <T extends DataBuffer> InputStream subscriberInputStream(Publisher<T> publisher, int demand) {
|
||||
Assert.notNull(publisher, "Publisher must not be null");
|
||||
Assert.isTrue(bufferSize > 0, "Buffer size must be > 0");
|
||||
Assert.isTrue(demand > 0, "maxBufferCount must be > 0");
|
||||
|
||||
InputStreamSubscriber inputStreamSubscriber = new InputStreamSubscriber(bufferSize);
|
||||
publisher.subscribe(inputStreamSubscriber);
|
||||
return inputStreamSubscriber;
|
||||
SubscriberInputStream subscriber = new SubscriberInputStream(demand);
|
||||
publisher.subscribe(subscriber);
|
||||
return subscriber;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -39,13 +39,13 @@ import org.springframework.util.Assert;
|
||||
* Bridges between {@link Publisher Publisher<DataBuffer>} and {@link InputStream}.
|
||||
*
|
||||
* <p>Note that this class has a near duplicate in
|
||||
* {@link org.springframework.http.client.InputStreamSubscriber}.
|
||||
* {@link org.springframework.http.client.SubscriberInputStream}.
|
||||
*
|
||||
* @author Oleh Dokuka
|
||||
* @author Rossen Stoyanchev
|
||||
* @since 6.2
|
||||
*/
|
||||
final class InputStreamSubscriber extends InputStream implements Subscriber<DataBuffer> {
|
||||
final class SubscriberInputStream extends InputStream implements Subscriber<DataBuffer> {
|
||||
|
||||
private static final Object READY = new Object();
|
||||
|
||||
@@ -82,10 +82,10 @@ final class InputStreamSubscriber extends InputStream implements Subscriber<Data
|
||||
private Throwable error;
|
||||
|
||||
|
||||
InputStreamSubscriber(int prefetch) {
|
||||
this.prefetch = prefetch;
|
||||
this.limit = (prefetch == Integer.MAX_VALUE ? Integer.MAX_VALUE : prefetch - (prefetch >> 2));
|
||||
this.queue = new ArrayBlockingQueue<>(prefetch);
|
||||
SubscriberInputStream(int demand) {
|
||||
this.prefetch = demand;
|
||||
this.limit = (demand == Integer.MAX_VALUE ? Integer.MAX_VALUE : demand - (demand >> 2));
|
||||
this.queue = new ArrayBlockingQueue<>(demand);
|
||||
this.lock = new ReentrantLock(false);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user