Skip to content

Commit ed4c451

Browse files
committed
moving metaDataCounter
1 parent 8de44f7 commit ed4c451

File tree

6 files changed

+9
-20
lines changed

6 files changed

+9
-20
lines changed

runtime/auth/aws-signing-common/api/aws-signing-common.api

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ public final class aws/smithy/kotlin/runtime/auth/awssigning/AwsChunkedByteReadC
1818
public fun isClosedForRead ()Z
1919
public fun isClosedForWrite ()Z
2020
public fun read (Laws/smithy/kotlin/runtime/io/SdkBuffer;JLkotlin/coroutines/Continuation;)Ljava/lang/Object;
21+
public final fun setTotalBytesTransferred (J)V
2122
}
2223

2324
public final class aws/smithy/kotlin/runtime/auth/awssigning/AwsChunkedSource : aws/smithy/kotlin/runtime/io/SdkSource {
@@ -26,6 +27,7 @@ public final class aws/smithy/kotlin/runtime/auth/awssigning/AwsChunkedSource :
2627
public fun close ()V
2728
public final fun getTotalBytesTransferred ()J
2829
public fun read (Laws/smithy/kotlin/runtime/io/SdkBuffer;J)J
30+
public final fun setTotalBytesTransferred (J)V
2931
}
3032

3133
public final class aws/smithy/kotlin/runtime/auth/awssigning/AwsSignatureType : java/lang/Enum {

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

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -48,20 +48,12 @@ public class AwsChunkedByteReadChannel(
4848
/**
4949
* Tracks the total bytes transferred, including chunk metadata.
5050
*/
51-
private var totalBytesTransferred: Long = 0L
52-
53-
/**
54-
* Gets the total bytes transferred for testing purposes only.
55-
*/
5651
@InternalApi
57-
public fun getTotalBytesTransferred(): Long = totalBytesTransferred
52+
public var totalBytesTransferred: Long = 0L
5853

5954
override suspend fun read(sink: SdkBuffer, limit: Long): Long {
6055
require(limit >= 0L) { "Invalid limit ($limit) must be >= 0L" }
6156

62-
// Reset metadata bytes counter
63-
chunkReader.chunkMetadataBytes = 0
64-
6557
if (!chunkReader.ensureValidChunk()) {
6658
totalBytesTransferred = -1L
6759
return -1L

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

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,20 +43,12 @@ public class AwsChunkedSource(
4343
/**
4444
* Tracks the total bytes transferred, including chunk metadata.
4545
*/
46-
private var totalBytesTransferred: Long = 0L
47-
48-
/**
49-
* Gets the total bytes transferred for testing purposes only.
50-
*/
5146
@InternalApi
52-
public fun getTotalBytesTransferred(): Long = totalBytesTransferred
47+
public var totalBytesTransferred: Long = 0L
5348

5449
override fun read(sink: SdkBuffer, limit: Long): Long {
5550
require(limit >= 0L) { "Invalid limit ($limit) must be >= 0L" }
5651

57-
// Reset metadata bytes counter
58-
chunkReader.chunkMetadataBytes = 0
59-
6052
// COROUTINE SAFETY: runBlocking is allowed here because SdkSource is a synchronous blocking interface
6153
val isChunkValid = runBlocking {
6254
chunkReader.ensureValidChunk()

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,9 @@ internal class AwsChunkedReader(
7171
* @return true if the [chunk] is valid for reading, false if it's invalid (chunk data is exhausted)
7272
*/
7373
internal suspend fun ensureValidChunk(): Boolean {
74+
// Reset metadata bytes counter
75+
chunkMetadataBytes = 0
76+
7477
// check if the current chunk is still valid
7578
if (chunk.size > 0L) return true
7679

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ fun interface AwsChunkedReaderFactory {
3535
// Override read function to track totalBytesTransferred for testing
3636
override suspend fun read(sink: SdkBuffer, limit: Long): Long {
3737
chunked.read(sink, limit)
38-
return chunked.getTotalBytesTransferred()
38+
return chunked.totalBytesTransferred
3939
}
4040
}
4141
}

runtime/auth/aws-signing-tests/jvm/src/aws/smithy/kotlin/runtime/auth/awssigning/tests/AwsChunkedSourceTestBase.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ val AwsChunkedReaderFactory.Companion.Source: AwsChunkedReaderFactory
2222
// Override read function to track totalBytesTransferred for testing
2323
override suspend fun read(sink: SdkBuffer, limit: Long): Long {
2424
chunked.read(sink, limit)
25-
return chunked.getTotalBytesTransferred()
25+
return chunked.totalBytesTransferred
2626
}
2727
}
2828
}

0 commit comments

Comments
 (0)