Package software.amazon.awssdk.core
Class ResponseBytes<ResponseT>
- java.lang.Object
-
- software.amazon.awssdk.core.BytesWrapper
-
- software.amazon.awssdk.core.ResponseBytes<ResponseT>
-
public final class ResponseBytes<ResponseT> extends BytesWrapper
An in-memory representation of the service's response from a streaming operation. This usually obtained by calling the "bytes" form of a streaming operation, like S3'sgetObjectBytes
. Can also be retrieved by passingResponseTransformer.toBytes()
orAsyncResponseTransformer.toBytes()
to a streaming output operation.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(Object o)
static <ResponseT>
ResponseBytes<ResponseT>fromByteArray(ResponseT response, byte[] bytes)
CreateResponseBytes
from a Byte array.static <ResponseT>
ResponseBytes<ResponseT>fromByteArrayUnsafe(ResponseT response, byte[] bytes)
CreateResponseBytes
from a Byte array without copying the contents of the byte array.static <ResponseT>
ResponseBytes<ResponseT>fromByteBufferUnsafe(ResponseT response, ByteBuffer buffer)
CreateResponseBytes
from aByteBuffer
with minimal copying.static <ResponseT>
ResponseBytes<ResponseT>fromInputStream(ResponseT response, InputStream stream)
CreateResponseBytes
from a Byte array.int
hashCode()
ResponseT
response()
String
toString()
-
Methods inherited from class software.amazon.awssdk.core.BytesWrapper
asByteArray, asByteArrayUnsafe, asByteBuffer, asContentStreamProvider, asInputStream, asString, asUtf8String
-
-
-
-
Method Detail
-
fromInputStream
public static <ResponseT> ResponseBytes<ResponseT> fromInputStream(ResponseT response, InputStream stream) throws UncheckedIOException
CreateResponseBytes
from a Byte array. This will copy the contents of the byte array.- Throws:
UncheckedIOException
-
fromByteArray
public static <ResponseT> ResponseBytes<ResponseT> fromByteArray(ResponseT response, byte[] bytes)
CreateResponseBytes
from a Byte array. This will copy the contents of the byte array.
-
fromByteArrayUnsafe
public static <ResponseT> ResponseBytes<ResponseT> fromByteArrayUnsafe(ResponseT response, byte[] bytes)
CreateResponseBytes
from a Byte array without copying the contents of the byte array. This introduces concurrency risks, allowing: (1) the caller to modify the byte array stored in thisSdkBytes
implementation AND (2) any users ofBytesWrapper.asByteArrayUnsafe()
to modify the byte array passed into thisSdkBytes
implementation.As the method name implies, this is unsafe. Use
fromByteArray(Object, byte[])
unless you're sure you know the risks.
-
fromByteBufferUnsafe
public static <ResponseT> ResponseBytes<ResponseT> fromByteBufferUnsafe(ResponseT response, ByteBuffer buffer)
CreateResponseBytes
from aByteBuffer
with minimal copying. This method attempts to avoid copying data when possible, but introduces concurrency risks in specific scenarios.Behavior by buffer type:
- Array-backed ByteBuffer (perfect match): When the buffer represents the entire backing array
(offset=0, remaining=array.length), the array is shared without copying. This introduces the same
concurrency risks as
fromByteArrayUnsafe(Object, byte[])
: modifications to the original backing array will affect the returnedResponseBytes
. - Array-backed ByteBuffer (partial): When the buffer represents only a portion of the backing array, data is copied to a new array. No concurrency risks.
- Direct ByteBuffer: Data is always copied to a heap array. No concurrency risks.
The buffer's position is preserved and not modified by this operation.
As the method name implies, this is unsafe in the first scenario. Use a safe alternative unless you're sure you know the risks.
- Array-backed ByteBuffer (perfect match): When the buffer represents the entire backing array
(offset=0, remaining=array.length), the array is shared without copying. This introduces the same
concurrency risks as
-
response
public ResponseT response()
- Returns:
- the unmarshalled response object from the service.
-
equals
public boolean equals(Object o)
- Overrides:
equals
in classBytesWrapper
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classBytesWrapper
-
-