Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ private long calculateExistingTrailersLength() {

private long calculateTrailerLength(Pair<String, List<String>> trailer) {
// size of trailer-header and colon
long lengthInBytes = trailer.left().length() + 1;
long lengthInBytes = trailer.left().length() + 1L;

// size of trailer-values
for (String value : trailer.right()) {
Expand All @@ -220,7 +220,7 @@ private long calculateTrailerLength(Pair<String, List<String>> trailer) {

private long calculateChecksumTrailerLength(String checksumHeaderName) {
// size of checksum trailer-header and colon
long lengthInBytes = checksumHeaderName.length() + 1;
long lengthInBytes = checksumHeaderName.length() + 1L;

// get the base checksum for the algorithm
SdkChecksum sdkChecksum = fromChecksumAlgorithm(checksumAlgorithm);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ private long calculateExistingTrailersLength() {

private long calculateTrailerLength(Pair<String, List<String>> trailer) {
// size of trailer-header and colon
long lengthInBytes = trailer.left().length() + 1;
long lengthInBytes = trailer.left().length() + 1L;

// size of trailer-values
for (String value : trailer.right()) {
Expand All @@ -239,7 +239,7 @@ private long calculateTrailerLength(Pair<String, List<String>> trailer) {

private long calculateChecksumTrailerLength(String checksumHeaderName) {
// size of checksum trailer-header and colon
long lengthInBytes = checksumHeaderName.length() + 1;
long lengthInBytes = checksumHeaderName.length() + 1L;

// get the base checksum for the algorithm
SdkChecksum sdkChecksum = fromChecksumAlgorithm(checksumAlgorithm);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ private void writeTrailers(ByteArrayOutputStream outputStream) throws IOExceptio
}

@Override
public void reset() throws IOException {
public synchronized void reset() throws IOException {
trailers.forEach(TrailerProvider::reset);
extensions.forEach(ChunkExtensionProvider::reset);
header.reset();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import java.time.Instant;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.util.Optional;
import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec;
import software.amazon.awssdk.annotations.SdkInternalApi;
Expand Down Expand Up @@ -190,7 +191,8 @@ public static void addDateHeader(SdkHttpRequest.Builder requestBuilder, String d
* the payload is read in its entirety to calculate the length.
*/
public static long moveContentLength(SdkHttpRequest.Builder request, InputStream payload) {
if (!request.firstMatchingHeader(X_AMZ_DECODED_CONTENT_LENGTH).isPresent()) {
Optional<String> decodedContentLength = request.firstMatchingHeader(X_AMZ_DECODED_CONTENT_LENGTH);
if (!decodedContentLength.isPresent()) {
// if the decoded length isn't present, content-length must be there
String contentLength = request.firstMatchingHeader(Header.CONTENT_LENGTH).orElseGet(
() -> String.valueOf(readAll(payload))
Expand All @@ -203,7 +205,7 @@ public static long moveContentLength(SdkHttpRequest.Builder request, InputStream

// decoded header is already there, so remove content-length just to be sure it's gone
request.removeHeader(Header.CONTENT_LENGTH);
return Long.parseLong(request.firstMatchingHeader(X_AMZ_DECODED_CONTENT_LENGTH).get());
return Long.parseLong(decodedContentLength.get());
}

private static MessageDigest getMessageDigestInstance() {
Expand Down