Skip to content

Commit b95efec

Browse files
misc: merge from main
2 parents 1ed5f16 + 4501fa9 commit b95efec

File tree

27 files changed

+158
-201
lines changed

27 files changed

+158
-201
lines changed

aws-crt-kotlin/build.gradle.kts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -224,10 +224,9 @@ private val KotlinNativeTarget.isBuildableOnHost: Boolean
224224
}
225225
}
226226

227-
private fun findMingwHome(): String =
228-
System.getenv("MINGW_PREFIX")?.takeUnless { it.isBlank() }
229-
?: typedProp("mingw.prefix")
230-
?: throw IllegalStateException(
231-
"Cannot determine MinGW prefix location. Please verify MinGW is installed correctly " +
232-
"and that either the `MINGW_PREFIX` environment variable or the `mingw.prefix` Gradle property is set.",
233-
)
227+
private fun findMingwHome(): String = System.getenv("MINGW_PREFIX")?.takeUnless { it.isBlank() }
228+
?: typedProp("mingw.prefix")
229+
?: throw IllegalStateException(
230+
"Cannot determine MinGW prefix location. Please verify MinGW is installed correctly " +
231+
"and that either the `MINGW_PREFIX` environment variable or the `mingw.prefix` Gradle property is set.",
232+
)

aws-crt-kotlin/common/src/aws/sdk/kotlin/crt/http/HttpClientConnectionManagerOptions.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,7 @@ public class HttpClientConnectionManagerOptions internal constructor(
5353
public const val DEFAULT_INITIAL_WINDOW_SIZE: Int = 16 * 1024
5454
public const val DEFAULT_MAX_CONNECTIONS: Int = 2
5555

56-
public fun build(block: HttpClientConnectionManagerOptionsBuilder.() -> Unit): HttpClientConnectionManagerOptions =
57-
HttpClientConnectionManagerOptionsBuilder().apply(block).build()
56+
public fun build(block: HttpClientConnectionManagerOptionsBuilder.() -> Unit): HttpClientConnectionManagerOptions = HttpClientConnectionManagerOptionsBuilder().apply(block).build()
5857
}
5958
}
6059

aws-crt-kotlin/common/src/aws/sdk/kotlin/crt/http/HttpStreamResponseHandler.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,7 @@ public interface HttpStreamResponseHandler {
6262
* @return The number of bytes to move the sliding window by. Repeatedly returning zero will eventually cause the
6363
* sliding window to fill up and data to stop flowing until the user slides the window back open.
6464
*/
65-
public fun onResponseBody(stream: HttpStream, bodyBytesIn: Buffer): Int =
66-
/* Optional Callback, ignore incoming response body by default unless user wants to capture it. */
65+
public fun onResponseBody(stream: HttpStream, bodyBytesIn: Buffer): Int = /* Optional Callback, ignore incoming response body by default unless user wants to capture it. */
6766
// FIXME - do we want to follow this pattern or just have a single way of incrementing the
6867
// window size through `Stream.incrementWindow()`?
6968
bodyBytesIn.len

aws-crt-kotlin/common/src/aws/sdk/kotlin/crt/io/TlsContext.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,4 @@ public expect class TlsContext(options: TlsContextOptions? = null) : Closeable {
1919
/**
2020
* Build and configure a TLS context in the given [block]
2121
*/
22-
public fun TlsContext.Companion.build(block: TlsContextOptionsBuilder.() -> Unit): TlsContext =
23-
TlsContextOptionsBuilder().apply(block).build().let { TlsContext(it) }
22+
public fun TlsContext.Companion.build(block: TlsContextOptionsBuilder.() -> Unit): TlsContext = TlsContextOptionsBuilder().apply(block).build().let { TlsContext(it) }

aws-crt-kotlin/common/src/aws/sdk/kotlin/crt/io/TlsContextOptions.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@ public class TlsContextOptions internal constructor(builder: TlsContextOptionsBu
2727

2828
public companion object {
2929

30-
public fun build(block: TlsContextOptionsBuilder.() -> Unit): TlsContextOptions =
31-
TlsContextOptionsBuilder().apply(block).build()
30+
public fun build(block: TlsContextOptionsBuilder.() -> Unit): TlsContextOptions = TlsContextOptionsBuilder().apply(block).build()
3231

3332
/**
3433
* Helper which creates a default set of TLS options for the current platform

aws-crt-kotlin/common/src/aws/sdk/kotlin/crt/util/CaseInsensitiveMap.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ private class CaseInsensitiveString(val s: String) {
1212
override fun toString(): String = s
1313
}
1414

15-
private fun String.toInsensitive(): CaseInsensitiveString =
16-
CaseInsensitiveString(this)
15+
private fun String.toInsensitive(): CaseInsensitiveString = CaseInsensitiveString(this)
1716

1817
/**
1918
* Map of case-insensitive [String] to [Value]

aws-crt-kotlin/common/src/aws/sdk/kotlin/crt/util/Digest.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@ public expect object Digest {
2020
* Get a hex string representation of [buffer]
2121
*/
2222
@OptIn(ExperimentalUnsignedTypes::class)
23-
public fun Digest.hex(buffer: ByteArray): String =
24-
buffer.asUByteArray().joinToString("") { it.toString(16).padStart(2, '0') }
23+
public fun Digest.hex(buffer: ByteArray): String = buffer.asUByteArray().joinToString("") { it.toString(16).padStart(2, '0') }
2524

2625
/**
2726
* Get a hex string representation of this byte array

aws-crt-kotlin/common/test/aws/sdk/kotlin/crt/http/HttpClientConnectionTest.kt

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ class HttpClientConnectionTest : CrtTest() {
7171
// bad ssl
7272
// assertConnect("https://rsa2048.badssl.com/")
7373
assertConnect("http://http.badssl.com/")
74-
assertConnectFails("https://expired.badssl.com/", "TLS (SSL) negotiation failed")
75-
assertConnectFails("https://self-signed.badssl.com/", "TLS (SSL) negotiation failed")
74+
assertConnectFails("https://expired.badssl.com/", setOf("TLS (SSL) negotiation failed", "tls certificate is malformed or not correctly formatted"))
75+
assertConnectFails("https://self-signed.badssl.com/", setOf("TLS (SSL) negotiation failed", "tls certificate is malformed or not correctly formatted"))
7676
}
7777

7878
/**
@@ -88,11 +88,14 @@ class HttpClientConnectionTest : CrtTest() {
8888
}
8989

9090
/**
91-
* Assert that an attempt to connect to the given [url] fails with the given [exceptionMessage]
91+
* Assert that an attempt to connect to the given [url] fails with any of the given [exceptionMessages]
9292
*/
93-
private suspend fun assertConnectFails(url: String, exceptionMessage: String) {
93+
private suspend fun assertConnectFails(url: String, exceptionMessages: Set<String>) {
9494
val ex = assertFails { connectAllCiphers(url) }
95-
assertTrue(ex.message!!.contains(exceptionMessage))
95+
assertTrue(
96+
exceptionMessages.any { ex.message!!.contains(it) },
97+
"Exception message \"${ex.message}\" did not contain any of the expected ${exceptionMessages.joinToString(prefix = "\"", postfix = "\"")}",
98+
)
9699
}
97100

98101
/**

aws-crt-kotlin/jvm/src/aws/sdk/kotlin/crt/CRT.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,11 @@ public actual object CRT {
3636
val logLevel = Log.LogLevel.valueOf(config.logLevel.name)
3737
when (config.logDestination) {
3838
LogDestination.None -> return@runBlocking
39+
3940
LogDestination.Stdout -> Log.initLoggingToStdout(logLevel)
41+
4042
LogDestination.Stderr -> Log.initLoggingToStderr(logLevel)
43+
4144
LogDestination.File -> {
4245
val logfile = config.logFile
4346
requireNotNull(logfile) { "log filename must be specified when LogDestination.File is specified" }

aws-crt-kotlin/jvm/src/aws/sdk/kotlin/crt/auth/credentials/StsAssumeRoleCredentialsProviderJVM.kt

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -38,30 +38,27 @@ internal actual constructor(
3838
}
3939

4040
// Convert the SDK version of CredentialsProvider type to the CRT version
41-
internal fun adapt(credentialsProvider: CredentialsProvider?): CredentialsProviderJni? =
42-
if (credentialsProvider == null) {
43-
null
44-
} else {
45-
toCrtCredentialsProvider(credentialsProvider)
46-
}
47-
48-
private fun toCrtCredentialsProvider(sdkCredentialsProvider: CredentialsProvider): CredentialsProviderJni =
49-
object : CredentialsProviderJni() {
41+
internal fun adapt(credentialsProvider: CredentialsProvider?): CredentialsProviderJni? = if (credentialsProvider == null) {
42+
null
43+
} else {
44+
toCrtCredentialsProvider(credentialsProvider)
45+
}
5046

51-
override fun getCredentials(): CompletableFuture<CredentialsJni> = runBlocking {
52-
val deferred = async(start = CoroutineStart.UNDISPATCHED) {
53-
toCrtCredentials(sdkCredentialsProvider.getCredentials())
54-
}
47+
private fun toCrtCredentialsProvider(sdkCredentialsProvider: CredentialsProvider): CredentialsProviderJni = object : CredentialsProviderJni() {
5548

56-
deferred.asCompletableFuture()
49+
override fun getCredentials(): CompletableFuture<CredentialsJni> = runBlocking {
50+
val deferred = async(start = CoroutineStart.UNDISPATCHED) {
51+
toCrtCredentials(sdkCredentialsProvider.getCredentials())
5752
}
53+
54+
deferred.asCompletableFuture()
5855
}
56+
}
5957

60-
private fun toCrtCredentials(sdkCredentials: Credentials): CredentialsJni =
61-
object : CredentialsJni() {
62-
override fun getAccessKeyId(): ByteArray = sdkCredentials.accessKeyId.encodeToByteArray()
58+
private fun toCrtCredentials(sdkCredentials: Credentials): CredentialsJni = object : CredentialsJni() {
59+
override fun getAccessKeyId(): ByteArray = sdkCredentials.accessKeyId.encodeToByteArray()
6360

64-
override fun getSecretAccessKey(): ByteArray = sdkCredentials.secretAccessKey.encodeToByteArray()
61+
override fun getSecretAccessKey(): ByteArray = sdkCredentials.secretAccessKey.encodeToByteArray()
6562

66-
override fun getSessionToken(): ByteArray = sdkCredentials.sessionToken?.encodeToByteArray() ?: ByteArray(0)
67-
}
63+
override fun getSessionToken(): ByteArray = sdkCredentials.sessionToken?.encodeToByteArray() ?: ByteArray(0)
64+
}

0 commit comments

Comments
 (0)