Skip to content

Commit fb8a0ca

Browse files
committed
lint
1 parent 8404a31 commit fb8a0ca

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

runtime/auth/aws-signing-common/common/src/aws/smithy/kotlin/runtime/auth/awssigning/internal/AwsChunkedReader.kt

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,7 @@ internal class AwsChunkedReader(
7272
*/
7373
internal suspend fun ensureValidChunk(): Boolean {
7474
// check if the current chunk is still valid
75-
if (chunk.size > 0L) {
76-
return true
77-
}
75+
if (chunk.size > 0L) return true
7876

7977
// if not, try to fetch a new chunk
8078
val nextChunk = when {
@@ -89,8 +87,10 @@ internal class AwsChunkedReader(
8987
next
9088
}
9189
}
90+
9291
val preTerminatorChunkSize = nextChunk?.size ?: 0L
9392
nextChunk?.writeUtf8("\r\n") // terminating CRLF to signal end of chunk
93+
9494
val chunkSizeWithTerminator = nextChunk?.size ?: 0L
9595
chunkMetadataBytes += chunkSizeWithTerminator - preTerminatorChunkSize
9696
// transfer all segments to the working chunk
@@ -106,6 +106,7 @@ internal class AwsChunkedReader(
106106
private suspend fun getFinalChunk(): SdkBuffer {
107107
// empty chunk
108108
val lastChunk = checkNotNull(if (signingConfig.isUnsigned) getUnsignedChunk(SdkBuffer()) else getSignedChunk(SdkBuffer()))
109+
109110
val preTrailerChunkSize = lastChunk.size
110111
// + any trailers
111112
if (!trailingHeaders.isEmpty()) {
@@ -167,6 +168,7 @@ internal class AwsChunkedReader(
167168
write(chunkSignature)
168169
writeUtf8("\r\n")
169170
}
171+
170172
chunkMetadataBytes += signedChunk.size
171173
// append the body
172174
signedChunk.write(chunkBody)
@@ -195,6 +197,7 @@ internal class AwsChunkedReader(
195197
writeUtf8("\r\n")
196198
writeAll(bodyBuffer) // append the body
197199
}
200+
198201
chunkMetadataBytes += unsignedChunk.size - bodyBytes
199202
return unsignedChunk
200203
}

runtime/auth/aws-signing-tests/common/src/aws/smithy/kotlin/runtime/auth/awssigning/tests/AwsChunkedByteReadChannelTestBase.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ abstract class AwsChunkedByteReadChannelTestBase : AwsChunkedTestBase(AwsChunked
4949

5050
val bytesAsString = sink.readUtf8()
5151

52-
assertEquals(dataLengthBytes.toLong() , bytesRead)
52+
assertEquals(dataLengthBytes.toLong(), bytesRead)
5353
assertTrue(awsChunked.isClosedForRead)
5454

5555
val chunkSignatures = getChunkSignatures(bytesAsString)

0 commit comments

Comments
 (0)