diff --git a/core/src/main/kotlin/com/retoday/core/domain/history/service/WebsiteService.kt b/core/src/main/kotlin/com/retoday/core/domain/history/service/WebsiteService.kt index 908eebe..185d60b 100644 --- a/core/src/main/kotlin/com/retoday/core/domain/history/service/WebsiteService.kt +++ b/core/src/main/kotlin/com/retoday/core/domain/history/service/WebsiteService.kt @@ -26,9 +26,10 @@ class WebsiteService( } } ?: try { websiteRepository - .save(Website(domain = domain, faviconUrl = faviconUrl)) + .saveAndFlush(Website(domain = domain, faviconUrl = faviconUrl)) .also { eventPublisher.publishEvent(WebsiteCategoryClassificationEvent(it.id!!, domain)) } } catch (e: DataIntegrityViolationException) { - websiteRepository.findByDomain(domain)!! + websiteRepository.findByDomain(domain) + ?: throw IllegalStateException("Website not found after duplicate key violation: $domain") } }