@Override
public void onSessionDown(final BGPSession session, final Exception e) {
- LOG.info("Session with peer {} went down", this.name, e);
+ if(e.getMessage().equals(BGPSessionImpl.END_OF_INPUT)) {
+ LOG.info("Session with peer {} went down", this.name);
+ } else {
+ LOG.info("Session with peer {} went down", this.name, e);
+ }
releaseConnection();
}
private static final int KA_TO_DEADTIMER_RATIO = 3;
+ static final String END_OF_INPUT = "End of input detected. Close the session.";
+
/**
* Internal session state.
*/
@Override
public synchronized void close() {
- LOG.info("Closing session: {}", this);
-
- if (this.state != State.IDLE) {
+ if (this.state != State.IDLE && this.channel.isActive()) {
this.writeAndFlush(new NotifyBuilder().setErrorCode(BGPError.CEASE.getCode()).setErrorSubcode(
- BGPError.CEASE.getSubcode()).build());
- removePeerSession();
- this.channel.close();
- this.state = State.IDLE;
+ BGPError.CEASE.getSubcode()).build());
}
+ this.closeWithoutMessage();
}
/**
public synchronized void endOfInput() {
if (this.state == State.UP) {
- this.listener.onSessionDown(this, new IOException("End of input detected. Close the session."));
+ LOG.info(END_OF_INPUT);
+ this.listener.onSessionDown(this, new IOException(END_OF_INPUT));
}
}
}
private synchronized void closeWithoutMessage() {
- LOG.debug("Closing session: {}", this);
+ LOG.info("Closing session: {}", this);
removePeerSession();
this.channel.close();
this.state = State.IDLE;
}
}).when(this.speakerListener).writeAndFlush(any(Notification.class));
doReturn(this.eventLoop).when(this.speakerListener).eventLoop();
+ doReturn(true).when(this.speakerListener).isActive();
doAnswer(new Answer<Void>() {
@Override
public Void answer(final InvocationOnMock invocation) throws Throwable {