From f72a61e8712d1b2e08c0e656cf1daa3be823970f Mon Sep 17 00:00:00 2001 From: Sjoerd Talsma Date: Sun, 1 Dec 2024 09:59:06 +0100 Subject: [PATCH] Clear service cache when capture exception occurs. Signed-off-by: Sjoerd Talsma --- .../java/nl/talsmasoftware/context/api/ContextSnapshotImpl.java | 1 + 1 file changed, 1 insertion(+) diff --git a/context-propagation-api/src/main/java/nl/talsmasoftware/context/api/ContextSnapshotImpl.java b/context-propagation-api/src/main/java/nl/talsmasoftware/context/api/ContextSnapshotImpl.java index 4ed0a2af..ef76a332 100644 --- a/context-propagation-api/src/main/java/nl/talsmasoftware/context/api/ContextSnapshotImpl.java +++ b/context-propagation-api/src/main/java/nl/talsmasoftware/context/api/ContextSnapshotImpl.java @@ -35,6 +35,7 @@ static ContextSnapshot capture() { return new ContextSnapshotImpl(); } catch (RuntimeException e) { SNAPSHOT_LOGGER.log(Level.FINEST, e, () -> "Error capturing ContextSnapshot from " + Thread.currentThread().getName() + ": " + e.getMessage()); + ServiceCache.clear(); throw error = e; } finally { timed(System.nanoTime() - start, ContextSnapshot.class, "capture", error);