BGP system test issue fix
Change-Id: I66958eeef622137ab5a3e75e172a6a5a5d0f1514
diff --git a/protocols/bgp/ctl/src/main/java/org/onosproject/bgp/controller/impl/BgpChannelHandler.java b/protocols/bgp/ctl/src/main/java/org/onosproject/bgp/controller/impl/BgpChannelHandler.java
index 0c55ead..3a605f4 100755
--- a/protocols/bgp/ctl/src/main/java/org/onosproject/bgp/controller/impl/BgpChannelHandler.java
+++ b/protocols/bgp/ctl/src/main/java/org/onosproject/bgp/controller/impl/BgpChannelHandler.java
@@ -472,21 +472,12 @@
log.info("[exceptionCaught]: " + e.toString());
if (e.getCause() instanceof ReadTimeoutException) {
- if ((ChannelState.OPENWAIT == state) || (ChannelState.OPENSENT == state)) {
-
- // When ReadTimeout timer is expired in OPENWAIT/OPENSENT state, it is considered
- sendNotification(BgpErrorType.HOLD_TIMER_EXPIRED, (byte) 0, null);
- channel.close();
- state = ChannelState.IDLE;
- return;
- } else if (ChannelState.OPENCONFIRM == state) {
-
- // When ReadTimeout timer is expired in OPENCONFIRM state.
- sendNotification(BgpErrorType.HOLD_TIMER_EXPIRED, (byte) 0, null);
- channel.close();
- state = ChannelState.IDLE;
- return;
- }
+ // device timeout
+ log.error("Disconnecting device {} due to read timeout", getPeerInfoString());
+ sendNotification(BgpErrorType.HOLD_TIMER_EXPIRED, (byte) 0, null);
+ state = ChannelState.IDLE;
+ ctx.getChannel().close();
+ return;
} else if (e.getCause() instanceof ClosedChannelException) {
log.debug("Channel for bgp {} already closed", getPeerInfoString());
} else if (e.getCause() instanceof IOException) {
@@ -495,7 +486,7 @@
// still print stack trace if debug is enabled
log.debug("StackTrace for previous Exception: ", e.getCause());
}
- channel.close();
+ ctx.getChannel().close();
} else if (e.getCause() instanceof BgpParseException) {
byte[] data = new byte[] {};
BgpParseException errMsg = (BgpParseException) e.getCause();
@@ -512,7 +503,7 @@
log.warn("Could not process message: queue full");
} else {
log.error("Error while processing message from peer " + getPeerInfoString() + "state " + this.state);
- channel.close();
+ ctx.getChannel().close();
}
}