The future returned from reconnect strategy may have completed before
we add a listener. Make sure we record the future before adding the
listener.
Also change checkState() to a verify() with a proper identity check
to work with nulls and a proper message.
JIRA: NETCONF-827
Change-Id: Ica152cd1445e797c122e542aa1138232f11c6736
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
package org.opendaylight.netconf.nettyutil;
import static com.google.common.base.Preconditions.checkState;
package org.opendaylight.netconf.nettyutil;
import static com.google.common.base.Preconditions.checkState;
+import static com.google.common.base.Verify.verify;
import static java.util.Objects.requireNonNull;
import io.netty.bootstrap.Bootstrap;
import static java.util.Objects.requireNonNull;
import io.netty.bootstrap.Bootstrap;
LOG.debug("Attempt to connect to {} failed", address, cf.cause());
final Future<Void> rf = strategy.scheduleReconnect(cf.cause());
LOG.debug("Attempt to connect to {} failed", address, cf.cause());
final Future<Void> rf = strategy.scheduleReconnect(cf.cause());
- rf.addListener(this::reconnectFutureComplete);
+ rf.addListener(this::reconnectFutureComplete);
}
// Triggered when a connection attempt is to be made.
private synchronized void reconnectFutureComplete(final Future<?> sf) {
LOG.debug("Promise {} strategy triggered reconnect", this);
}
// Triggered when a connection attempt is to be made.
private synchronized void reconnectFutureComplete(final Future<?> sf) {
LOG.debug("Promise {} strategy triggered reconnect", this);
- checkState(pending.equals(sf));
+ verify(pending == sf, "Completed strategy future %s while pending %s", sf, pending);
/*
* The promise we gave out could have been cancelled,
/*
* The promise we gave out could have been cancelled,