Commit ea228164 authored by akwizgran's avatar akwizgran

Check that poller instance isn't reused.

parent 4b5ad9ac
Pipeline #3464 passed with stage
in 7 minutes and 31 seconds
......@@ -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<PendingContact> pending = db.getPendingContacts(txn);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment