From fad48e1de38c681d2d33e7e6136536e862901474 Mon Sep 17 00:00:00 2001 From: Kai Moritz Date: Sat, 9 Nov 2024 16:56:32 +0100 Subject: [PATCH] =?utf8?q?M=C3=B6gliche=20Exception=20wegen=20konkurrieren?= =?utf8?q?dem=20Zugriff=20auf=20Map=20verhindert?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- src/main/java/de/juplo/kafka/CounterState.java | 2 +- src/main/java/de/juplo/kafka/CounterStateController.java | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/main/java/de/juplo/kafka/CounterState.java b/src/main/java/de/juplo/kafka/CounterState.java index 715a97a..804e247 100644 --- a/src/main/java/de/juplo/kafka/CounterState.java +++ b/src/main/java/de/juplo/kafka/CounterState.java @@ -19,6 +19,6 @@ public class CounterState public synchronized Map getCounterState() { - return counterState; + return new HashMap<>(counterState); } } diff --git a/src/main/java/de/juplo/kafka/CounterStateController.java b/src/main/java/de/juplo/kafka/CounterStateController.java index 723a8d0..ace87a9 100644 --- a/src/main/java/de/juplo/kafka/CounterStateController.java +++ b/src/main/java/de/juplo/kafka/CounterStateController.java @@ -4,7 +4,6 @@ import lombok.RequiredArgsConstructor; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController; -import java.util.HashMap; import java.util.Map; @@ -17,6 +16,6 @@ public class CounterStateController @GetMapping Map> getAllCounters() { - return new HashMap<>(consumer.getCounterState()); + return consumer.getCounterState(); } } -- 2.20.1