From 96fb075233285e60f0e1668270fed3ccb2390804 Mon Sep 17 00:00:00 2001 From: Dominic Byrd-McDevitt Date: Thu, 23 Apr 2026 11:19:31 -0400 Subject: [PATCH] fix: use SLF4J logger in circuit breaker callbacks instead of context.log MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Akka Typed's context.log is only safe to call from within the actor's message-processing thread. CircuitBreaker onOpen/onHalfOpen/onClose callbacks fire on a Future dispatcher thread, so context.log accesses the ActorLogger from the wrong thread — resulting in the state-transition log lines never reaching CloudWatch. Replace context.log with the object-level SLF4J logger (already present as `log`), which is thread-safe and callable from any thread. Co-Authored-By: Claude Sonnet 4.6 --- src/main/scala/dpla/api/v2/search/ElasticSearchClient.scala | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/scala/dpla/api/v2/search/ElasticSearchClient.scala b/src/main/scala/dpla/api/v2/search/ElasticSearchClient.scala index 42b70ab..ecf369f 100644 --- a/src/main/scala/dpla/api/v2/search/ElasticSearchClient.scala +++ b/src/main/scala/dpla/api/v2/search/ElasticSearchClient.scala @@ -139,9 +139,9 @@ object ElasticSearchClient { maxFailures = maxFailures, callTimeout = callTimeout, resetTimeout = resetTimeout - ).onOpen(() => context.log.warn("ElasticSearch circuit breaker opened")) - .onClose(() => context.log.info("ElasticSearch circuit breaker closed")) - .onHalfOpen(() => context.log.info("ElasticSearch circuit breaker half-open, testing ES")) + ).onOpen(() => log.warn("ElasticSearch circuit breaker opened")) + .onClose(() => log.info("ElasticSearch circuit breaker closed")) + .onHalfOpen(() => log.info("ElasticSearch circuit breaker half-open, testing ES")) Behaviors.receiveMessage[IntermediateSearchResult] {