- timeout = this.timer.newTimeout(new TimerTask() {
- @Override
- @SuppressWarnings("checkstyle:hiddenField")
- public void run(final Timeout timeout) {
- synchronized (this) {
- if (state != State.ESTABLISHED) {
-
- LOG.debug("Connection timeout after {}, session is in state {}", timeout, state);
-
- // Do not fail negotiation if promise is done or canceled
- // It would result in setting result of the promise second time and that throws exception
- if (!isPromiseFinished()) {
- LOG.warn("Netconf session was not established after {}", connectionTimeoutMillis);
- changeState(State.FAILED);
-
- channel.close().addListener((GenericFutureListener<ChannelFuture>) future -> {
- if (future.isSuccess()) {
- LOG.debug("Channel {} closed: success", future.channel());
- } else {
- LOG.warn("Channel {} closed: fail", future.channel());
- }
- });
- }
- } else if (channel.isOpen()) {
- channel.pipeline().remove(NAME_OF_EXCEPTION_HANDLER);
- }
- }
- }