Package io.micronaut.http.body.stream
Class PublisherAsBlocking<T>
java.lang.Object
io.micronaut.http.body.stream.PublisherAsBlocking<T>
- Type Parameters:
T- Stream type
- All Implemented Interfaces:
Closeable,AutoCloseable,Subscriber<T>
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).voidvoidvoidvoidprotected voidtake()Get the next object.
-
Constructor Details
-
PublisherAsBlocking
public PublisherAsBlocking()
-
-
Method Details
-
release
-
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<T>
-
onNext
- Specified by:
onNextin interfaceSubscriber<T>
-
onError
- Specified by:
onErrorin interfaceSubscriber<T>
-
onComplete
public void onComplete()- Specified by:
onCompletein interfaceSubscriber<T>
-
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
-