From 28c1fd5407a1095f95542053c56fc99ebfc63df7 Mon Sep 17 00:00:00 2001 From: Noah Bjerkli Aanonli Date: Fri, 16 Aug 2024 09:55:46 +0200 Subject: [PATCH] Do not complete on timeout --- .../kotlin/no/nb/mlt/wls/order/service/OrderService.kt | 1 - .../no/nb/mlt/wls/product/service/ProductService.kt | 9 ++++----- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/main/kotlin/no/nb/mlt/wls/order/service/OrderService.kt b/src/main/kotlin/no/nb/mlt/wls/order/service/OrderService.kt index 2485bbe6..979432af 100644 --- a/src/main/kotlin/no/nb/mlt/wls/order/service/OrderService.kt +++ b/src/main/kotlin/no/nb/mlt/wls/order/service/OrderService.kt @@ -50,7 +50,6 @@ class OrderService(val db: OrderRepository, val synqService: SynqOrderService) { "Timed out while fetching from WLS database. Relevant payload: $payload" } } - .onErrorComplete(TimeoutException::class.java) .awaitSingleOrNull() } } diff --git a/src/main/kotlin/no/nb/mlt/wls/product/service/ProductService.kt b/src/main/kotlin/no/nb/mlt/wls/product/service/ProductService.kt index 7f532bf2..d3423b98 100644 --- a/src/main/kotlin/no/nb/mlt/wls/product/service/ProductService.kt +++ b/src/main/kotlin/no/nb/mlt/wls/product/service/ProductService.kt @@ -47,7 +47,7 @@ class ProductService(val db: ProductRepository, val synqProductService: SynqProd db.save(product) .timeout(Duration.ofSeconds(6)) .onErrorMap { - throw ServerErrorException("Failed to save product in the database, but created in the storage system", it) + ServerErrorException("Failed to save product in the database, but created in the storage system", it) } .awaitSingle() @@ -76,12 +76,11 @@ class ProductService(val db: ProductRepository, val synqProductService: SynqProd // TODO - See if timeouts can be made configurable return db.findByHostNameAndHostId(hostName, name) .timeout(Duration.ofSeconds(8)) - .doOnError { - if (it is TimeoutException) { - logger.error(it, { "Timed out while fetching from WLS database" }) + .doOnError(TimeoutException::class.java) { + logger.error(it) { + "Timed out while fetching from WLS database" } } - .onErrorComplete(TimeoutException::class.java) .awaitSingleOrNull() } }