Class SdkLengthAwareInputStream

java.lang.Object
java.io.InputStream
java.io.FilterInputStream
software.amazon.awssdk.core.internal.io.SdkLengthAwareInputStream
All Implemented Interfaces:
Closeable, AutoCloseable

public class SdkLengthAwareInputStream extends FilterInputStream
An InputStream that is aware of its length. This class enforces that we sent exactly the number of bytes equal to the input length. If the wrapped stream has more bytes than the expected length, it will be truncated to length. If the stream has less bytes (i.e. reaches EOF) before the expected length is reached, it will throw IOException.