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
-
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
The failure fromonError(Throwable)
.void
void
void
void
protected void
take()
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
null
if either the stream is not done, or the stream completed successfully.
-
onSubscribe
- Specified by:
onSubscribe
in interfaceSubscriber<T>
-
onNext
- Specified by:
onNext
in interfaceSubscriber<T>
-
onError
- Specified by:
onError
in interfaceSubscriber<T>
-
onComplete
public void onComplete()- Specified by:
onComplete
in interfaceSubscriber<T>
-
take
Get the next object.- Returns:
- The next object, or
null
if the stream is done - Throws:
InterruptedException
-
close
public void close()- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
-