diff --git a/network/tor/tor/src/main/java/bisq/tor/controller/TorController.java b/network/tor/tor/src/main/java/bisq/tor/controller/TorController.java index 31a625d772..fae516887c 100644 --- a/network/tor/tor/src/main/java/bisq/tor/controller/TorController.java +++ b/network/tor/tor/src/main/java/bisq/tor/controller/TorController.java @@ -33,7 +33,7 @@ public class TorController implements BootstrapEventListener, HsDescEventListene @Getter private final Observable bootstrapEvent = new Observable<>(); - private final Map onionServicePublishedLatchMap = new ConcurrentHashMap<>(); + private final Map pendingOnionServicePublishLatchMap = new ConcurrentHashMap<>(); private Optional torControlProtocol = Optional.empty(); @@ -70,7 +70,7 @@ public void bootstrapTor() throws IOException { public void publish(TorKeyPair torKeyPair, int onionServicePort, int localPort) throws IOException, InterruptedException { String onionAddress = torKeyPair.getOnionAddress(); var onionServicePublishedLatch = new CountDownLatch(1); - onionServicePublishedLatchMap.put(onionAddress, onionServicePublishedLatch); + pendingOnionServicePublishLatchMap.put(onionAddress, onionServicePublishedLatch); subscribeToHsDescEvents(); TorControlProtocol torControlProtocol = getTorControlProtocol(); @@ -123,8 +123,11 @@ public void onHsDescEvent(HsDescEvent hsDescEvent) { log.info("Tor HS_DESC event: {}", hsDescEvent); if (hsDescEvent.getAction() == HsDescEvent.Action.UPLOADED) { String onionAddress = hsDescEvent.getHsAddress() + ".onion"; - CountDownLatch countDownLatch = onionServicePublishedLatchMap.get(onionAddress); - countDownLatch.countDown(); + CountDownLatch countDownLatch = pendingOnionServicePublishLatchMap.get(onionAddress); + if (countDownLatch != null) { + countDownLatch.countDown(); + pendingOnionServicePublishLatchMap.remove(onionAddress); + } } }