From 400c173ffe0bc135d702f2ccb1bb8bf45dd7c2a0 Mon Sep 17 00:00:00 2001 From: timfn-hg Date: Wed, 8 Jan 2025 08:18:42 -0600 Subject: [PATCH] chore: Synchronize around local reference to collection instead of synchronizing on the getter result directly (#17250) Signed-off-by: Tim Farber-Newman --- .../swirlds/platform/gui/internal/WinTabAddresses.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/gui/internal/WinTabAddresses.java b/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/gui/internal/WinTabAddresses.java index 1ad4b8feac62..73ccd4550cc9 100644 --- a/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/gui/internal/WinTabAddresses.java +++ b/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/gui/internal/WinTabAddresses.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2016-2024 Hedera Hashgraph, LLC + * Copyright (C) 2016-2025 Hedera Hashgraph, LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,10 +20,12 @@ import static com.swirlds.platform.gui.internal.BrowserWindowManager.getPlatforms; import com.hedera.hapi.node.state.roster.RosterEntry; +import com.swirlds.platform.SwirldsPlatform; import com.swirlds.platform.gui.GuiUtils; import com.swirlds.platform.gui.components.PrePaintableJPanel; import com.swirlds.platform.roster.RosterUtils; import com.swirlds.platform.system.Platform; +import java.util.Collection; import javax.swing.JTextArea; /** @@ -51,8 +53,10 @@ public void prePaint() { } redoWindow = false; String s = ""; - synchronized (getPlatforms()) { - for (final Platform p : getPlatforms()) { + final Collection platforms = getPlatforms(); + + synchronized (platforms) { + for (final Platform p : platforms) { final RosterEntry entry = RosterUtils.getRosterEntry(p.getRoster(), p.getSelfId().id()); final String name = RosterUtils.formatNodeName(entry.nodeId());