Skip to content

Commit 44b7d47

Browse files
committed
lint
1 parent 5bd6de2 commit 44b7d47

File tree

8 files changed

+55
-59
lines changed

8 files changed

+55
-59
lines changed

aws-runtime/aws-config/common/src/aws/sdk/kotlin/runtime/config/profile/AwsProfile.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ public inline fun <reified T : Enum<T>> AwsProfile.getEnumSetOrNull(key: String,
239239
append(value)
240240
append("' is not supported, should be one of: ")
241241
enumValues<T>().joinTo(this) { it.name.lowercase() }
242-
}
242+
},
243243
)
244244
}.toSet()
245245
.takeIf { it.isNotEmpty() }

codegen/aws-sdk-codegen/src/main/kotlin/aws/sdk/kotlin/codegen/customization/sqs/SqsMd5ChecksumValidationIntegration.kt

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,12 @@ class SqsMd5ChecksumValidationIntegration : KotlinIntegration {
2929
}
3030

3131
internal object SqsMd5ChecksumValidationMiddleware : ProtocolMiddleware {
32-
override fun isEnabledFor(ctx: ProtocolGenerator.GenerationContext, op: OperationShape): Boolean {
33-
return when (op.id.name) {
34-
"ReceiveMessage",
35-
"SendMessage",
36-
"SendMessageBatch" -> true
37-
else -> false
38-
}
32+
override fun isEnabledFor(ctx: ProtocolGenerator.GenerationContext, op: OperationShape): Boolean = when (op.id.name) {
33+
"ReceiveMessage",
34+
"SendMessage",
35+
"SendMessageBatch",
36+
-> true
37+
else -> false
3938
}
4039

4140
override val name: String = "SqsMd5ChecksumValidationInterceptor"

services/sqs/common/src/aws.sdk.kotlin.services.sqs/SqsMd5ChecksumValidationInterceptor.kt

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ public class SqsMd5ChecksumValidationInterceptor(
103103
sendMessageRequest: SendMessageRequest,
104104
sendMessageResponse: SendMessageResponse,
105105
) {
106-
if(validationScopes.contains(ValidationScope.MESSAGE_BODY)) {
106+
if (validationScopes.contains(ValidationScope.MESSAGE_BODY)) {
107107
val messageBodySent = sendMessageRequest.messageBody
108108

109109
if (!messageBodySent.isNullOrEmpty()) {
@@ -117,7 +117,7 @@ public class SqsMd5ChecksumValidationInterceptor(
117117
}
118118
}
119119

120-
if(validationScopes.contains(ValidationScope.MESSAGE_ATTRIBUTES)) {
120+
if (validationScopes.contains(ValidationScope.MESSAGE_ATTRIBUTES)) {
121121
val messageAttrSent = sendMessageRequest.messageAttributes
122122
if (!messageAttrSent.isNullOrEmpty()) {
123123
logger.debug { "Validating message attribute MD5 checksum for SendMessage" }
@@ -130,7 +130,7 @@ public class SqsMd5ChecksumValidationInterceptor(
130130
}
131131
}
132132

133-
if(validationScopes.contains(ValidationScope.MESSAGE_SYSTEM_ATTRIBUTES)) {
133+
if (validationScopes.contains(ValidationScope.MESSAGE_SYSTEM_ATTRIBUTES)) {
134134
val messageSysAttrSent = sendMessageRequest.messageSystemAttributes
135135
if (!messageSysAttrSent.isNullOrEmpty()) {
136136
logger.debug { "Validating message system attribute MD5 checksum for SendMessage" }
@@ -148,7 +148,7 @@ public class SqsMd5ChecksumValidationInterceptor(
148148
val messages = receiveMessageResponse.messages
149149
if (messages != null) {
150150
for (messageReceived in messages) {
151-
if(validationScopes.contains(ValidationScope.MESSAGE_BODY)) {
151+
if (validationScopes.contains(ValidationScope.MESSAGE_BODY)) {
152152
val messageBody = messageReceived.body
153153
if (!messageBody.isNullOrEmpty()) {
154154
logger.debug { "Validating message body MD5 checksum for ReceiveMessage" }
@@ -161,7 +161,7 @@ public class SqsMd5ChecksumValidationInterceptor(
161161
}
162162
}
163163

164-
if(validationScopes.contains(ValidationScope.MESSAGE_ATTRIBUTES)) {
164+
if (validationScopes.contains(ValidationScope.MESSAGE_ATTRIBUTES)) {
165165
val messageAttr = messageReceived.messageAttributes
166166

167167
if (!messageAttr.isNullOrEmpty()) {
@@ -191,7 +191,7 @@ public class SqsMd5ChecksumValidationInterceptor(
191191
}
192192

193193
for (entry in sendMessageBatchResponse.successful) {
194-
if(validationScopes.contains(ValidationScope.MESSAGE_BODY)) {
194+
if (validationScopes.contains(ValidationScope.MESSAGE_BODY)) {
195195
val messageBody = idToRequestEntryMap[entry.id]?.messageBody
196196

197197
if (!messageBody.isNullOrEmpty()) {
@@ -205,7 +205,7 @@ public class SqsMd5ChecksumValidationInterceptor(
205205
}
206206
}
207207

208-
if(validationScopes.contains(ValidationScope.MESSAGE_ATTRIBUTES)) {
208+
if (validationScopes.contains(ValidationScope.MESSAGE_ATTRIBUTES)) {
209209
val messageAttrSent = idToRequestEntryMap[entry.id]?.messageAttributes
210210
if (!messageAttrSent.isNullOrEmpty()) {
211211
logger.debug { "Validating message attribute MD5 checksum for SendMessageBatch: ${entry.messageId}" }
@@ -218,7 +218,7 @@ public class SqsMd5ChecksumValidationInterceptor(
218218
}
219219
}
220220

221-
if(validationScopes.contains(ValidationScope.MESSAGE_SYSTEM_ATTRIBUTES)) {
221+
if (validationScopes.contains(ValidationScope.MESSAGE_SYSTEM_ATTRIBUTES)) {
222222
val messageSysAttrSent = idToRequestEntryMap[entry.id]?.messageSystemAttributes
223223
if (!messageSysAttrSent.isNullOrEmpty()) {
224224
logger.debug { "Validating message system attribute MD5 checksum for SendMessageBatch: ${entry.messageId}" }
@@ -239,9 +239,9 @@ public class SqsMd5ChecksumValidationInterceptor(
239239
} catch (e: Exception) {
240240
throw ClientException(
241241
"Unable to calculate the MD5 hash of the message body." +
242-
"Potential reasons include JVM configuration or FIPS compliance issues." +
243-
"To disable message MD5 validation, you can set checksumValidationEnabled" +
244-
"to false when instantiating the client." + e.message,
242+
"Potential reasons include JVM configuration or FIPS compliance issues." +
243+
"To disable message MD5 validation, you can set checksumValidationEnabled" +
244+
"to false when instantiating the client." + e.message,
245245
)
246246
}
247247
val expectedMD5Hex = expectedMD5.toHexString()
@@ -300,18 +300,17 @@ public class SqsMd5ChecksumValidationInterceptor(
300300
} catch (e: Exception) {
301301
throw ClientException(
302302
"Unable to calculate the MD5 hash of the message body." +
303-
"Potential reasons include JVM configuration or FIPS compliance issues." +
304-
"To disable message MD5 validation, you can set checksumValidationEnabled" +
305-
"to false when instantiating the client." + e.message,
303+
"Potential reasons include JVM configuration or FIPS compliance issues." +
304+
"To disable message MD5 validation, you can set checksumValidationEnabled" +
305+
"to false when instantiating the client." + e.message,
306306
)
307307
}
308308
val expectedMD5Hex = md5Digest.digest().toHexString()
309309
return expectedMD5Hex
310310
}
311311

312312
private fun calculateMessageSystemAttributesMd5(
313-
messageSysAttrs:
314-
Map<MessageSystemAttributeNameForSends, MessageSystemAttributeValue>,
313+
messageSysAttrs: Map<MessageSystemAttributeNameForSends, MessageSystemAttributeValue>,
315314
): String {
316315
val sortedAttributeNames = messageSysAttrs.keys.sortedBy { it.value }
317316
val md5Digest = Md5()
@@ -359,9 +358,9 @@ public class SqsMd5ChecksumValidationInterceptor(
359358
} catch (e: Exception) {
360359
throw ClientException(
361360
"Unable to calculate the MD5 hash of the message body." +
362-
"Potential reasons include JVM configuration or FIPS compliance issues." +
363-
"To disable message MD5 validation, you can set checksumValidationEnabled" +
364-
"to false when instantiating the client." + e.message,
361+
"Potential reasons include JVM configuration or FIPS compliance issues." +
362+
"To disable message MD5 validation, you can set checksumValidationEnabled" +
363+
"to false when instantiating the client." + e.message,
365364
)
366365
}
367366
val expectedMD5Hex = md5Digest.digest().toHexString()

services/sqs/common/src/aws.sdk.kotlin.services.sqs/internal/FinalizeSqsConfig.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ internal suspend fun finalizeSqsConfig(
1919
builder.config.checksumValidationEnabled = builder.config.checksumValidationEnabled
2020
?: SQSSetting.checksumValidationEnabled.resolve(provider)
2121
?: activeProfile.checksumValidationEnabled
22-
?: ValidationEnabled.NEVER //TODO: MD5 checksum validation is temporarily disabled. Set default to ALWAYS in next minor version
22+
?: ValidationEnabled.NEVER // TODO: MD5 checksum validation is temporarily disabled. Set default to ALWAYS in next minor version
2323

2424
builder.config.checksumValidationScopes = builder.config.checksumValidationScopes.ifEmpty {
2525
SQSSetting.checksumValidationScopes.resolve(provider)

services/sqs/common/src/aws.sdk.kotlin.services.sqs/internal/SQSSetting.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ internal object SQSSetting {
2525
*
2626
* Note: Value matching is case-insensitive when configured via environment variables.
2727
*/
28-
public val checksumValidationEnabled : EnvironmentSetting<ValidationEnabled> =
28+
public val checksumValidationEnabled: EnvironmentSetting<ValidationEnabled> =
2929
enumEnvSetting("aws.SqsChecksumValidationEnabled", "AWS_SQS_CHECKSUM_VALIDATION_ENABLED")
3030

3131
/**

services/sqs/common/src/aws.sdk.kotlin.services.sqs/internal/ValidationConfig.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public enum class ValidationEnabled {
2121
ALWAYS,
2222
WHEN_SENDING,
2323
WHEN_RECEIVING,
24-
NEVER
24+
NEVER,
2525
}
2626

2727
/**
@@ -42,5 +42,5 @@ public enum class ValidationEnabled {
4242
public enum class ValidationScope {
4343
MESSAGE_ATTRIBUTES,
4444
MESSAGE_SYSTEM_ATTRIBUTES,
45-
MESSAGE_BODY
45+
MESSAGE_BODY,
4646
}

services/sqs/e2eTest/src/SqsMd5ChecksumValidationTest.kt

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -136,15 +136,15 @@ class SqsMd5ChecksumValidationTest {
136136
TEST_MESSAGE_ATTRIBUTES_NAME to MessageAttributeValue {
137137
dataType = "String"
138138
stringValue = TEST_MESSAGE_ATTRIBUTES_VALUE
139-
}
139+
},
140140
)
141141
messageSystemAttributes = hashMapOf(
142142
MessageSystemAttributeNameForSends.AwsTraceHeader to MessageSystemAttributeValue {
143143
dataType = "String"
144144
stringValue = TEST_MESSAGE_SYSTEM_ATTRIBUTES_VALUE
145-
}
145+
},
146146
)
147-
}
147+
},
148148
)
149149
}
150150
}
@@ -158,7 +158,7 @@ class SqsMd5ChecksumValidationTest {
158158
maxNumberOfMessages = 1
159159
messageAttributeNames = listOf(TEST_MESSAGE_ATTRIBUTES_NAME)
160160
messageSystemAttributeNames = listOf(MessageSystemAttributeName.AwsTraceHeader)
161-
}
161+
},
162162
)
163163
}
164164
}
@@ -174,31 +174,31 @@ class SqsMd5ChecksumValidationTest {
174174
SendMessageBatchRequest {
175175
queueUrl = correctChecksumTestQueueUrl
176176
this.entries = entries
177-
}
177+
},
178178
)
179179
}
180180
}
181181

182182
@Test
183183
fun testSendMessageWithWrongChecksum(): Unit = runBlocking {
184184
val exception = assertThrows<ChecksumMismatchException> {
185-
wrongChecksumClient.sendMessage (
185+
wrongChecksumClient.sendMessage(
186186
SendMessageRequest {
187187
queueUrl = wrongChecksumTestQueueUrl
188188
messageBody = TEST_MESSAGE_BODY
189189
messageAttributes = hashMapOf(
190190
TEST_MESSAGE_ATTRIBUTES_NAME to MessageAttributeValue {
191191
dataType = "String"
192192
stringValue = TEST_MESSAGE_ATTRIBUTES_VALUE
193-
}
193+
},
194194
)
195195
messageSystemAttributes = hashMapOf(
196196
MessageSystemAttributeNameForSends.AwsTraceHeader to MessageSystemAttributeValue {
197197
dataType = "String"
198198
stringValue = TEST_MESSAGE_SYSTEM_ATTRIBUTES_VALUE
199-
}
199+
},
200200
)
201-
}
201+
},
202202
)
203203
}
204204

@@ -214,7 +214,7 @@ class SqsMd5ChecksumValidationTest {
214214
maxNumberOfMessages = 1
215215
messageAttributeNames = listOf(TEST_MESSAGE_ATTRIBUTES_NAME)
216216
messageSystemAttributeNames = listOf(MessageSystemAttributeName.AwsTraceHeader)
217-
}
217+
},
218218
)
219219
}
220220

@@ -232,7 +232,7 @@ class SqsMd5ChecksumValidationTest {
232232
SendMessageBatchRequest {
233233
queueUrl = wrongChecksumTestQueueUrl
234234
this.entries = entries
235-
}
235+
},
236236
)
237237
}
238238

services/sqs/e2eTest/src/SqsTestUtils.kt

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -89,22 +89,20 @@ object SqsTestUtils {
8989
}
9090
}
9191

92-
fun buildSendMessageBatchRequestEntry(batchId: Int): SendMessageBatchRequestEntry{
93-
return SendMessageBatchRequestEntry {
94-
id = batchId.toString()
95-
messageBody = TEST_MESSAGE_BODY + batchId
96-
messageAttributes = hashMapOf(
97-
TEST_MESSAGE_ATTRIBUTES_NAME to MessageAttributeValue {
98-
dataType = "String"
99-
stringValue = TEST_MESSAGE_ATTRIBUTES_VALUE + batchId
100-
}
101-
)
102-
messageSystemAttributes = hashMapOf(
103-
MessageSystemAttributeNameForSends.AwsTraceHeader to MessageSystemAttributeValue {
104-
dataType = "String"
105-
stringValue = TEST_MESSAGE_SYSTEM_ATTRIBUTES_VALUE + batchId
106-
}
107-
)
108-
}
92+
fun buildSendMessageBatchRequestEntry(batchId: Int): SendMessageBatchRequestEntry = SendMessageBatchRequestEntry {
93+
id = batchId.toString()
94+
messageBody = TEST_MESSAGE_BODY + batchId
95+
messageAttributes = hashMapOf(
96+
TEST_MESSAGE_ATTRIBUTES_NAME to MessageAttributeValue {
97+
dataType = "String"
98+
stringValue = TEST_MESSAGE_ATTRIBUTES_VALUE + batchId
99+
},
100+
)
101+
messageSystemAttributes = hashMapOf(
102+
MessageSystemAttributeNameForSends.AwsTraceHeader to MessageSystemAttributeValue {
103+
dataType = "String"
104+
stringValue = TEST_MESSAGE_SYSTEM_ATTRIBUTES_VALUE + batchId
105+
},
106+
)
109107
}
110108
}

0 commit comments

Comments
 (0)