Package io.micronaut.http.body.stream
Class PublisherAsBlocking
java.lang.Object
io.micronaut.http.body.stream.PublisherAsBlocking
- All Implemented Interfaces:
Closeable,AutoCloseable,Subscriber<ReadBuffer>
@Internal
public final class PublisherAsBlocking
extends Object
implements Subscriber<ReadBuffer>, Closeable
A subscriber that allows blocking reads from a publisher. Handles resource cleanup properly.
- Since:
- 4.2.0
- Author:
- Jonas Konrad
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()The failure fromonError(Throwable).voidvoidvoidonNext(ReadBuffer o) voidtake()Get the next object.
-
Constructor Details
-
PublisherAsBlocking
public PublisherAsBlocking()
-
-
Method Details
-
getFailure
The failure fromonError(Throwable). Whentake()returnsnull, this may be set if the reactive stream ended in failure.- Returns:
- The failure, or
nullif either the stream is not done, or the stream completed successfully.
-
onSubscribe
- Specified by:
onSubscribein interfaceSubscriber<ReadBuffer>
-
onNext
- Specified by:
onNextin interfaceSubscriber<ReadBuffer>
-
onError
- Specified by:
onErrorin interfaceSubscriber<ReadBuffer>
-
onComplete
public void onComplete()- Specified by:
onCompletein interfaceSubscriber<ReadBuffer>
-
take
Get the next object.- Returns:
- The next object, or
nullif the stream is done - Throws:
InterruptedException
-
close
public void close()- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
-