}
}
+ /**
+ * Handle exception occurred in the PCEP session. The session in error state should be closed
+ * properly so that it can be restored later.
+ */
+ @VisibleForTesting
+ void handleException(final Throwable cause) {
+ LOG.error("Exception captured for session {}, closing session.", this, cause);
+ terminate(TerminationReason.UNKNOWN);
+ }
+
/**
* Sends message to serialization.
*
}
@VisibleForTesting
- public void sessionUp() {
- this.listener.onSessionUp(this);
+ void sessionUp() {
+ try {
+ this.listener.onSessionUp(this);
+ } catch (final Exception e) {
+ handleException(e);
+ throw e;
+ }
}
@VisibleForTesting
- protected final Queue<Long> getUnknownMessagesTimes() {
+ final Queue<Long> getUnknownMessagesTimes() {
return this.unknownMessagesTimes;
}
this.sessionUp();
}
+ @Override
+ public void exceptionCaught(final ChannelHandlerContext ctx, final Throwable cause) {
+ handleException(cause);
+ }
+
@Override
public Tlvs localSessionCharacteristics() {
return this.localOpen.getTlvs();