Skip to content

Commit 1dafa6c

Browse files
authored
fix: LogMode isEnabled behavior (#1038)
1 parent e90ab68 commit 1dafa6c

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"id": "01ea7858-c080-447f-9bd1-93bdec3f0161",
3+
"type": "bugfix",
4+
"description": "Fix LogMode unintentionally enabling *WithBody modes"
5+
}

runtime/smithy-client/common/src/aws/smithy/kotlin/runtime/client/LogMode.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public sealed class LogMode(private val mask: Int) {
6262
/**
6363
* Test if a particular [LogMode] is enabled
6464
*/
65-
public fun isEnabled(mode: LogMode): Boolean = mask and mode.mask != 0
65+
public fun isEnabled(mode: LogMode): Boolean = mask and mode.mask == mode.mask
6666

6767
public companion object {
6868
/**

runtime/smithy-client/common/test/aws/smithy/kotlin/runtime/client/LogModeTest.kt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,4 +66,13 @@ class LogModeTest {
6666
assertTrue(LogMode.LogResponseWithBody.isEnabled(LogMode.LogResponse))
6767
assertFalse(LogMode.LogResponseWithBody.isEnabled(LogMode.LogRequest))
6868
}
69+
70+
@Test
71+
fun testWithoutBodyDoesNotImplyWith() {
72+
// LogRequest does NOT imply LogRequestWithBody
73+
assertFalse(LogMode.LogRequest.isEnabled(LogMode.LogRequestWithBody))
74+
75+
// LogResponse does NOT imply LogResponseWithBody
76+
assertFalse(LogMode.LogResponse.isEnabled(LogMode.LogResponseWithBody))
77+
}
6978
}

0 commit comments

Comments
 (0)