diff --git a/build.gradle.kts b/build.gradle.kts index 915325e..f28814b 100755 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -6,7 +6,7 @@ allprojects { group = "com.ucasoft.ktor" - version = "0.4.3" + version = "0.4.4" repositories { mavenCentral() diff --git a/ktor-simple-cache/README.md b/ktor-simple-cache/README.md index 8fbf675..325cc06 100755 --- a/ktor-simple-cache/README.md +++ b/ktor-simple-cache/README.md @@ -1,7 +1,7 @@ # Ktor Simple Cache Base solution which provides the plugin implementation and abstract class for cache providers. -[![Maven Central with version prefix filter](https://img.shields.io/maven-central/v/com.ucasoft.ktor/ktor-simple-cache/0.4.3?color=blue)](https://search.maven.org/artifact/com.ucasoft.ktor/ktor-simple-cache/0.4.3/jar) +[![Maven Central with version prefix filter](https://img.shields.io/maven-central/v/com.ucasoft.ktor/ktor-simple-cache/0.4.4?color=blue)](https://search.maven.org/artifact/com.ucasoft.ktor/ktor-simple-cache/0.4.4/jar) ## Setup ### Gradle ```kotlin @@ -9,7 +9,7 @@ repositories { mavenCentral() } -implementation("com.ucasoft.ktor:ktor-simple-cache:0.4.3") +implementation("com.ucasoft.ktor:ktor-simple-cache:0.4.4") ``` ## Usage ```kotlin diff --git a/ktor-simple-cache/src/main/kotlin/com/ucasoft/ktor/simpleCache/SimpleCachePlugin.kt b/ktor-simple-cache/src/main/kotlin/com/ucasoft/ktor/simpleCache/SimpleCachePlugin.kt index af41ea7..c73c929 100755 --- a/ktor-simple-cache/src/main/kotlin/com/ucasoft/ktor/simpleCache/SimpleCachePlugin.kt +++ b/ktor-simple-cache/src/main/kotlin/com/ucasoft/ktor/simpleCache/SimpleCachePlugin.kt @@ -2,6 +2,7 @@ package com.ucasoft.ktor.simpleCache import io.ktor.http.* import io.ktor.server.application.* +import io.ktor.server.application.hooks.* import io.ktor.server.request.* import io.ktor.server.response.* import io.ktor.util.* @@ -24,6 +25,10 @@ val SimpleCachePlugin = createRouteScopedPlugin(name = "SimpleCachePlugin", ::Si it.respond(cache) } } + on(CallFailed) { _, e -> + provider.badResponse() + throw e + } onCallRespond { call, body -> if ((call.response.status() ?: HttpStatusCode.OK) >= HttpStatusCode.BadRequest) { provider.badResponse() diff --git a/ktor-simple-cache/src/test/kotlin/com/ucasoft/ktor/simpleCache/SimpleCacheTests.kt b/ktor-simple-cache/src/test/kotlin/com/ucasoft/ktor/simpleCache/SimpleCacheTests.kt index 5313c02..04ffaed 100755 --- a/ktor-simple-cache/src/test/kotlin/com/ucasoft/ktor/simpleCache/SimpleCacheTests.kt +++ b/ktor-simple-cache/src/test/kotlin/com/ucasoft/ktor/simpleCache/SimpleCacheTests.kt @@ -157,6 +157,29 @@ internal class SimpleCacheTests { } } + @Test + fun `check route thrown exceptions aren not locked`() { + with(buildTestEngine(buildProvider(), Application::testApplication)) { + + runBlocking { + val totalThreads = 100 + val deferred = (1..totalThreads).map { + async { + shouldThrow { + client.get("/exception") + } + } + } + + val result = deferred.awaitAll().map { it.message }.groupBy { it } + .map { it.key to it.value.size } + result.shouldBeSingleton { + it.second.shouldBe(totalThreads) + } + } + } + } + @Test fun `check all parameters`() { val firstCacheKey = "/check?param1=value1¶m2=value2" diff --git a/ktor-simple-cache/src/test/kotlin/com/ucasoft/ktor/simpleCache/TestApplication.kt b/ktor-simple-cache/src/test/kotlin/com/ucasoft/ktor/simpleCache/TestApplication.kt index b130191..b7bcf76 100755 --- a/ktor-simple-cache/src/test/kotlin/com/ucasoft/ktor/simpleCache/TestApplication.kt +++ b/ktor-simple-cache/src/test/kotlin/com/ucasoft/ktor/simpleCache/TestApplication.kt @@ -30,6 +30,9 @@ fun Application.testApplication() { get("/bad") { call.respond(HttpStatusCode.BadRequest, "Bad request") } + get("/exception") { + throw RuntimeException("Just an exception") + } } } } diff --git a/ktor-simple-memory-cache/README.md b/ktor-simple-memory-cache/README.md index 9a8abc3..78fec5d 100755 --- a/ktor-simple-memory-cache/README.md +++ b/ktor-simple-memory-cache/README.md @@ -1,7 +1,7 @@ # Ktor Simple Memory Cache Memory cache provider for Ktor Simple Cache plugin -[![Maven Central with version prefix filter](https://img.shields.io/maven-central/v/com.ucasoft.ktor/ktor-simple-memory-cache/0.4.3?color=blue)](https://search.maven.org/artifact/com.ucasoft.ktor/ktor-simple-memory-cache/0.4.3/jar) +[![Maven Central with version prefix filter](https://img.shields.io/maven-central/v/com.ucasoft.ktor/ktor-simple-memory-cache/0.4.4?color=blue)](https://search.maven.org/artifact/com.ucasoft.ktor/ktor-simple-memory-cache/0.4.4/jar) ## Setup ### Gradle ```kotlin @@ -9,7 +9,7 @@ repositories { mavenCentral() } -implementation("com.ucasoft.ktor:ktor-simple-memory-cache:0.4.3") +implementation("com.ucasoft.ktor:ktor-simple-memory-cache:0.4.4") ``` ## Usage ```kotlin diff --git a/ktor-simple-redis-cache/README.md b/ktor-simple-redis-cache/README.md index 0368958..f560942 100755 --- a/ktor-simple-redis-cache/README.md +++ b/ktor-simple-redis-cache/README.md @@ -1,7 +1,7 @@ # Ktor Simple Redis Cache Redis cache provider for Ktor Simple Cache plugin -[![Maven Central with version prefix filter](https://img.shields.io/maven-central/v/com.ucasoft.ktor/ktor-simple-redis-cache/0.4.3?color=blue)](https://search.maven.org/artifact/com.ucasoft.ktor/ktor-simple-redis-cache/0.4.3/jar) +[![Maven Central with version prefix filter](https://img.shields.io/maven-central/v/com.ucasoft.ktor/ktor-simple-redis-cache/0.4.4?color=blue)](https://search.maven.org/artifact/com.ucasoft.ktor/ktor-simple-redis-cache/0.4.4/jar) ## Setup ### Gradle ```kotlin @@ -9,7 +9,7 @@ repositories { mavenCentral() } -implementation("com.ucasoft.ktor:ktor-simple-redis-cache:0.4.3") +implementation("com.ucasoft.ktor:ktor-simple-redis-cache:0.4.4") ``` ## Usage ```kotlin