Package io.micronaut.http.body
Class ReactiveByteBufferByteBody.SharedBuffer
java.lang.Object
io.micronaut.http.body.stream.BaseSharedBuffer<io.micronaut.http.body.ReactiveByteBufferByteBody.ByteBufferConsumer,ByteBuffer>
io.micronaut.http.body.ReactiveByteBufferByteBody.SharedBuffer
- All Implemented Interfaces:
BufferConsumer
- Enclosing class:
- ReactiveByteBufferByteBody
public static final class ReactiveByteBufferByteBody.SharedBuffer
extends BaseSharedBuffer<io.micronaut.http.body.ReactiveByteBufferByteBody.ByteBufferConsumer,ByteBuffer>
Simple implementation of
Buffering is done using a
BaseSharedBuffer
that consumes ByteBuffer
s.Buffering is done using a
ByteArrayOutputStream
. Concurrency control is done through
a non-reentrant lock based on AtomicReference
.-
Nested Class Summary
Nested classes/interfaces inherited from class io.micronaut.http.body.stream.BaseSharedBuffer
BaseSharedBuffer.AsFlux<B>
Nested classes/interfaces inherited from interface io.micronaut.http.body.stream.BufferConsumer
BufferConsumer.Upstream
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
add
(ByteBuffer buffer) protected void
Buffer the input buffer.protected void
addForward
(List<io.micronaut.http.body.ReactiveByteBufferByteBody.ByteBufferConsumer> consumers) Forward the input buffer to the given list of consumers.void
complete()
Implementation ofBufferConsumer.complete()
.
Not thread safe, caller must handle concurrency.protected void
Discard the previously buffered bytes.void
Implementation ofBufferConsumer.error(Throwable)
.
Not thread safe, caller must handle concurrency.protected void
forwardInitialBuffer
(@Nullable io.micronaut.http.body.ReactiveByteBufferByteBody.ByteBufferConsumer subscriber, boolean last) Forward any already-buffered data to the given new subscriber.subscribeFull
(BufferConsumer.Upstream specificUpstream) protected ByteBuffer
subscribeFullResult
(boolean last) Called aftercompletion
to get the data that should be forwarded to aBaseSharedBuffer.subscribeFull0(io.micronaut.core.execution.DelayedExecutionFlow<F>, io.micronaut.http.body.stream.BufferConsumer.Upstream, boolean)
subscriber.Methods inherited from class io.micronaut.http.body.stream.BaseSharedBuffer
add, addDoNotBuffer, afterSubscribe, failClaim, getExpectedLength, getLimits, getRootUpstream, logClaim, reserve0, setExpectedLength, setExpectedLengthFrom, subscribe0, subscribeFull0
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface io.micronaut.http.body.stream.BufferConsumer
discard
-
Constructor Details
-
SharedBuffer
-
-
Method Details
-
subscribeFull
-
forwardInitialBuffer
protected void forwardInitialBuffer(@Nullable @Nullable io.micronaut.http.body.ReactiveByteBufferByteBody.ByteBufferConsumer subscriber, boolean last) Description copied from class:BaseSharedBuffer
Forward any already-buffered data to the given new subscriber.- Specified by:
forwardInitialBuffer
in classBaseSharedBuffer<io.micronaut.http.body.ReactiveByteBufferByteBody.ByteBufferConsumer,
ByteBuffer> - Parameters:
subscriber
- The new subscriber, ornull
if the reservation has been cancelled and the data can just be discardedlast
-true
iff this was the last reservation and the buffer can be discarded after this call
-
subscribeFullResult
Description copied from class:BaseSharedBuffer
Called aftercompletion
to get the data that should be forwarded to aBaseSharedBuffer.subscribeFull0(io.micronaut.core.execution.DelayedExecutionFlow<F>, io.micronaut.http.body.stream.BufferConsumer.Upstream, boolean)
subscriber.- Specified by:
subscribeFullResult
in classBaseSharedBuffer<io.micronaut.http.body.ReactiveByteBufferByteBody.ByteBufferConsumer,
ByteBuffer> - Parameters:
last
-true
iff this was the last reservation and the buffer can be discarded after this call- Returns:
- The full result that should be returned from the
BaseSharedBuffer.subscribeFull0(io.micronaut.core.execution.DelayedExecutionFlow<F>, io.micronaut.http.body.stream.BufferConsumer.Upstream, boolean)
execution flow
-
addForward
protected void addForward(List<io.micronaut.http.body.ReactiveByteBufferByteBody.ByteBufferConsumer> consumers) Description copied from class:BaseSharedBuffer
Forward the input buffer to the given list of consumers.- Specified by:
addForward
in classBaseSharedBuffer<io.micronaut.http.body.ReactiveByteBufferByteBody.ByteBufferConsumer,
ByteBuffer> - Parameters:
consumers
- The consumers to forward the data to- See Also:
-
addBuffer
protected void addBuffer()Description copied from class:BaseSharedBuffer
Buffer the input buffer.- Specified by:
addBuffer
in classBaseSharedBuffer<io.micronaut.http.body.ReactiveByteBufferByteBody.ByteBufferConsumer,
ByteBuffer> - See Also:
-
discardBuffer
protected void discardBuffer()Description copied from class:BaseSharedBuffer
Discard the previously buffered bytes.- Specified by:
discardBuffer
in classBaseSharedBuffer<io.micronaut.http.body.ReactiveByteBufferByteBody.ByteBufferConsumer,
ByteBuffer> - See Also:
-
add
-
error
Description copied from class:BaseSharedBuffer
Implementation ofBufferConsumer.error(Throwable)
.
Not thread safe, caller must handle concurrency.- Specified by:
error
in interfaceBufferConsumer
- Overrides:
error
in classBaseSharedBuffer<io.micronaut.http.body.ReactiveByteBufferByteBody.ByteBufferConsumer,
ByteBuffer> - Parameters:
e
- The error
-
complete
public void complete()Description copied from class:BaseSharedBuffer
Implementation ofBufferConsumer.complete()
.
Not thread safe, caller must handle concurrency.- Specified by:
complete
in interfaceBufferConsumer
- Overrides:
complete
in classBaseSharedBuffer<io.micronaut.http.body.ReactiveByteBufferByteBody.ByteBufferConsumer,
ByteBuffer>
-