diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index 7cdfe17bbc4..831e18ae9ff 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -179,7 +179,7 @@ jobs: - name: jvmTest (K2 enabled) uses: gradle/gradle-build-action@v2 with: - arguments: "jvmTest -Pkotlin_version=2.0.0-dev-5387 -Pkotlin_repo_url=https://maven.pkg.jetbrains.space/kotlin/p/kotlin/bootstrap -Pkotlin_language_version=2.0" + arguments: "jvmTest -Pkotlin_version=2.0.0-dev-6573 -Pkotlin_repo_url=https://maven.pkg.jetbrains.space/kotlin/p/kotlin/bootstrap -Pkotlin_language_version=2.0 -Pkotlin_api_version=2.0" - name: Upload reports if: failure() diff --git a/arrow-libs/core/arrow-core/src/commonTest/kotlin/arrow/core/IterableTest.kt b/arrow-libs/core/arrow-core/src/commonTest/kotlin/arrow/core/IterableTest.kt index 7a1fe712366..06880e53fa7 100644 --- a/arrow-libs/core/arrow-core/src/commonTest/kotlin/arrow/core/IterableTest.kt +++ b/arrow-libs/core/arrow-core/src/commonTest/kotlin/arrow/core/IterableTest.kt @@ -1,3 +1,5 @@ +@file:Suppress("DUPLICATE_PARAMETER_NAME_IN_FUNCTION_TYPE") + package arrow.core import arrow.core.test.either diff --git a/arrow-libs/core/arrow-core/src/commonTest/kotlin/arrow/core/SequenceKTest.kt b/arrow-libs/core/arrow-core/src/commonTest/kotlin/arrow/core/SequenceKTest.kt index e7a315b4ed3..f6ff9ec73aa 100644 --- a/arrow-libs/core/arrow-core/src/commonTest/kotlin/arrow/core/SequenceKTest.kt +++ b/arrow-libs/core/arrow-core/src/commonTest/kotlin/arrow/core/SequenceKTest.kt @@ -1,3 +1,5 @@ +@file:Suppress("DUPLICATE_PARAMETER_NAME_IN_FUNCTION_TYPE") + package arrow.core import arrow.core.test.laws.MonoidLaws diff --git a/arrow-libs/fx/arrow-fx-coroutines/src/commonMain/kotlin/arrow/fx/coroutines/CircuitBreaker.kt b/arrow-libs/fx/arrow-fx-coroutines/src/commonMain/kotlin/arrow/fx/coroutines/CircuitBreaker.kt index 3395f32f401..ec07859b4a4 100644 --- a/arrow-libs/fx/arrow-fx-coroutines/src/commonMain/kotlin/arrow/fx/coroutines/CircuitBreaker.kt +++ b/arrow-libs/fx/arrow-fx-coroutines/src/commonMain/kotlin/arrow/fx/coroutines/CircuitBreaker.kt @@ -621,26 +621,31 @@ private constructor( onClosed: suspend () -> Unit = { }, onHalfOpen: suspend () -> Unit = { }, onOpen: suspend () -> Unit = { }, - ): CircuitBreaker = - CircuitBreaker( + ): CircuitBreaker { + require(maxFailures >= 0) { + "maxFailures expected to be greater than or equal to 0, but was $maxFailures" + } + require(resetTimeoutNanos > 0) { + "resetTimeout expected to be greater than 0, but was $resetTimeoutNanos" + } + require(exponentialBackoffFactor > 0) { + "exponentialBackoffFactor expected to be greater than 0, but was $exponentialBackoffFactor" + } + require(maxResetTimeoutNanos > 0) { + "maxResetTimeout expected to be greater than 0, but was $maxResetTimeoutNanos" + } + return CircuitBreaker( state = AtomicRef(Closed(0)), - maxFailures = maxFailures - .takeIf { it >= 0 } - .let { requireNotNull(it) { "maxFailures expected to be greater than or equal to 0, but was $maxFailures" } }, - resetTimeoutNanos = resetTimeoutNanos - .takeIf { it > 0 } - .let { requireNotNull(it) { "resetTimeout expected to be greater than 0, but was $resetTimeoutNanos" } }, - exponentialBackoffFactor = exponentialBackoffFactor - .takeIf { it > 0 } - .let { requireNotNull(it) { "exponentialBackoffFactor expected to be greater than 0, but was $exponentialBackoffFactor" } }, - maxResetTimeoutNanos = maxResetTimeoutNanos - .takeIf { it > 0 } - .let { requireNotNull(it) { "maxResetTimeout expected to be greater than 0, but was $maxResetTimeoutNanos" } }, + maxFailures = maxFailures, + resetTimeoutNanos = resetTimeoutNanos, + exponentialBackoffFactor = exponentialBackoffFactor, + maxResetTimeoutNanos = maxResetTimeoutNanos, onRejected = onRejected, onClosed = onClosed, onHalfOpen = onHalfOpen, onOpen = onOpen ) + } /** * Attempts to create a [CircuitBreaker]. @@ -682,20 +687,10 @@ private constructor( onOpen: suspend () -> Unit = suspend { }, ): CircuitBreaker = of( - maxFailures = maxFailures - .takeIf { it >= 0 } - .let { requireNotNull(it) { "maxFailures expected to be greater than or equal to 0, but was $maxFailures" } }, - resetTimeoutNanos = resetTimeout - .takeIf { it.isPositive() && it != Duration.ZERO } - .let { requireNotNull(it) { "resetTimeout expected to be greater than ${Duration.ZERO}, but was $resetTimeout" } } - .toDouble(DurationUnit.NANOSECONDS), - exponentialBackoffFactor = exponentialBackoffFactor - .takeIf { it > 0 } - .let { requireNotNull(it) { "exponentialBackoffFactor expected to be greater than 0, but was $exponentialBackoffFactor" } }, - maxResetTimeoutNanos = maxResetTimeout - .takeIf { it.isPositive() && it != Duration.ZERO } - .let { requireNotNull(it) { "maxResetTimeout expected to be greater than ${Duration.ZERO}, but was $maxResetTimeout" } } - .toDouble(DurationUnit.NANOSECONDS), + maxFailures = maxFailures, + resetTimeoutNanos = resetTimeout.toDouble(DurationUnit.NANOSECONDS), + exponentialBackoffFactor = exponentialBackoffFactor, + maxResetTimeoutNanos = maxResetTimeout.toDouble(DurationUnit.NANOSECONDS), onRejected = onRejected, onClosed = onClosed, onHalfOpen = onHalfOpen, diff --git a/arrow-libs/resilience/arrow-resilience/src/commonMain/kotlin/arrow/resilience/CircuitBreaker.kt b/arrow-libs/resilience/arrow-resilience/src/commonMain/kotlin/arrow/resilience/CircuitBreaker.kt index e56372e3285..e348f127c4c 100644 --- a/arrow-libs/resilience/arrow-resilience/src/commonMain/kotlin/arrow/resilience/CircuitBreaker.kt +++ b/arrow-libs/resilience/arrow-resilience/src/commonMain/kotlin/arrow/resilience/CircuitBreaker.kt @@ -520,24 +520,28 @@ private constructor( onClosed: suspend () -> Unit = suspend { }, onHalfOpen: suspend () -> Unit = suspend { }, onOpen: suspend () -> Unit = suspend { } - ): CircuitBreaker = - CircuitBreaker( + ): CircuitBreaker { + require(resetTimeout > Duration.ZERO) { + "resetTimeout expected to be greater than ${Duration.ZERO}, but was $resetTimeout" + } + require(exponentialBackoffFactor > 0) { + "exponentialBackoffFactor expected to be greater than 0, but was $exponentialBackoffFactor" + } + require(maxResetTimeout > Duration.ZERO) { + "maxResetTimeout expected to be greater than ${Duration.ZERO}, but was $maxResetTimeout" + } + return CircuitBreaker( state = AtomicRef(Closed(openingStrategy)), - resetTimeout = resetTimeout - .takeIf { it.isPositive() && it != Duration.ZERO } - .let { requireNotNull(it) { "resetTimeout expected to be greater than ${Duration.ZERO}, but was $resetTimeout" } }, - exponentialBackoffFactor = exponentialBackoffFactor - .takeIf { it > 0 } - .let { requireNotNull(it) { "exponentialBackoffFactor expected to be greater than 0, but was $exponentialBackoffFactor" } }, - maxResetTimeout = maxResetTimeout - .takeIf { it.isPositive() && it != Duration.ZERO } - .let { requireNotNull(it) { "maxResetTimeout expected to be greater than ${Duration.ZERO}, but was $maxResetTimeout" } }, + resetTimeout = resetTimeout, + exponentialBackoffFactor = exponentialBackoffFactor, + maxResetTimeout = maxResetTimeout, timeSource = timeSource, onRejected = onRejected, onClosed = onClosed, onHalfOpen = onHalfOpen, onOpen = onOpen ) + } } public sealed class OpeningStrategy { diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index b3a0cc1b9e4..b368df8aa8d 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -8,15 +8,15 @@ dokka = "1.9.10" jUnit = "4.13.2" jUnitJupiter = "5.10.0" jUnitVintage = "5.10.0" -kotest = "5.7.2" -kotestGradle = "5.7.2" +kotest = "5.8.0" +kotestGradle = "5.8.0" kover = "0.7.4" -kotlin = "1.9.10" -kotlinxSerializationPlugin = "1.9.10" +kotlin = "1.9.20" +kotlinxSerializationPlugin = "1.9.20" kotlinBinaryCompatibilityValidator = "0.13.2" kotlinCompileTesting = "1.5.0" knit = "0.4.0" -kspVersion = "1.9.10-1.0.13" +kspVersion = "1.9.20-1.0.14" kotlinxSerialization = "1.6.0" mockWebServer = "4.12.0" retrofit = "2.9.0"