From ea228164dc9dd9556d242a8cac196efd4454bb95 Mon Sep 17 00:00:00 2001 From: akwizgran Date: Thu, 6 Jun 2019 12:10:42 +0100 Subject: [PATCH] Check that poller instance isn't reused. --- .../briarproject/bramble/rendezvous/RendezvousPollerImpl.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/bramble-core/src/main/java/org/briarproject/bramble/rendezvous/RendezvousPollerImpl.java b/bramble-core/src/main/java/org/briarproject/bramble/rendezvous/RendezvousPollerImpl.java index b7d355548..11340b233 100644 --- a/bramble-core/src/main/java/org/briarproject/bramble/rendezvous/RendezvousPollerImpl.java +++ b/bramble-core/src/main/java/org/briarproject/bramble/rendezvous/RendezvousPollerImpl.java @@ -47,6 +47,7 @@ import java.util.Map; import java.util.Map.Entry; import java.util.concurrent.Executor; import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.atomic.AtomicBoolean; import java.util.logging.Logger; import javax.annotation.Nullable; @@ -79,6 +80,7 @@ class RendezvousPollerImpl implements RendezvousPoller, Service, EventListener { private final EventBus eventBus; private final Clock clock; + private final AtomicBoolean used = new AtomicBoolean(false); // Executor that runs one task at a time private final Executor worker; // The following fields are only accessed on the worker @@ -113,6 +115,7 @@ class RendezvousPollerImpl implements RendezvousPoller, Service, EventListener { @Override public void startService() throws ServiceException { + if (used.getAndSet(true)) throw new IllegalStateException(); try { db.transaction(true, txn -> { Collection pending = db.getPendingContacts(txn);