From 30a5b22a2fc6c11c8014697e7299aa5b7cf623ca Mon Sep 17 00:00:00 2001 From: Jeff Xiang Date: Fri, 13 Dec 2024 17:29:10 -0500 Subject: [PATCH] Wrap metrics() in sychronized block to try and prevent CME --- psc/src/main/java/com/pinterest/psc/consumer/PscConsumer.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/psc/src/main/java/com/pinterest/psc/consumer/PscConsumer.java b/psc/src/main/java/com/pinterest/psc/consumer/PscConsumer.java index c242321..12ea1af 100644 --- a/psc/src/main/java/com/pinterest/psc/consumer/PscConsumer.java +++ b/psc/src/main/java/com/pinterest/psc/consumer/PscConsumer.java @@ -1902,7 +1902,9 @@ public Map metrics() throws ClientException { ensureOpen(); Map metrics = new ConcurrentHashMap<>(); for (PscBackendConsumer backendConsumer : backendConsumers) { - metrics.putAll(backendConsumer.metrics()); + synchronized (backendConsumer.metrics()) { + metrics.putAll(backendConsumer.metrics()); + } } return metrics; }