Fix checkstyle in AbstractBGPSessionNegotiator 16/80816/2
authorRobert Varga <robert.varga@pantheon.tech>
Wed, 13 Mar 2019 10:18:45 +0000 (11:18 +0100)
committerRobert Varga <robert.varga@pantheon.tech>
Wed, 13 Mar 2019 11:46:09 +0000 (12:46 +0100)
- session refers to instance field
- supress Exception catches
- rename argument

Change-Id: I1647435e13b8ac62b578916faa8a4f5ad8b69ba3
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/AbstractBGPSessionNegotiator.java

index 7069bba2738de45bd9700f21372ea8970e17f1a8..e001e9f76eda0fdcd5d04eb43040c0d29f1cefd8 100644 (file)
@@ -88,6 +88,7 @@ abstract class AbstractBGPSessionNegotiator extends ChannelInboundHandlerAdapter
         this.registry = registry;
     }
 
+    @SuppressWarnings("checkstyle:illegalCatch")
     private synchronized void startNegotiation() {
         if (!(this.state == State.IDLE || this.state == State.OPEN_CONFIRM)) {
             return;
@@ -154,7 +155,7 @@ abstract class AbstractBGPSessionNegotiator extends ChannelInboundHandlerAdapter
                 break;
             case OPEN_CONFIRM:
                 if (msg instanceof Keepalive) {
-                    negotiationSuccessful(this.session);
+                    negotiationSuccessful();
                     LOG.info("BGP Session with peer {} established successfully.", this.channel);
                 } else if (msg instanceof Notify) {
                     final Notify ntf = (Notify) msg;
@@ -210,19 +211,19 @@ abstract class AbstractBGPSessionNegotiator extends ChannelInboundHandlerAdapter
         }
     }
 
-    private synchronized void negotiationFailed(final Throwable e) {
-        LOG.warn("Channel {} negotiation failed: {}", this.channel, e.getMessage());
-        if (e instanceof BGPDocumentedException) {
+    private synchronized void negotiationFailed(final Throwable cause) {
+        LOG.warn("Channel {} negotiation failed: {}", this.channel, cause.getMessage());
+        if (cause instanceof BGPDocumentedException) {
             // although sendMessage() can also result in calling this method, it won't create a cycle.
             // In case sendMessage() fails to deliver the message, this method gets called with different
             // exception (definitely not with BGPDocumentedException).
-            sendMessage(buildErrorNotify(((BGPDocumentedException) e).getError(),
-                    ((BGPDocumentedException) e).getData()));
+            sendMessage(buildErrorNotify(((BGPDocumentedException) cause).getError(),
+                    ((BGPDocumentedException) cause).getData()));
         }
         if (this.state == State.OPEN_CONFIRM) {
             this.registry.removePeerSession(getRemoteIp());
         }
-        negotiationFailedCloseChannel(e);
+        negotiationFailedCloseChannel(cause);
         this.state = State.FINISHED;
     }
 
@@ -248,7 +249,8 @@ abstract class AbstractBGPSessionNegotiator extends ChannelInboundHandlerAdapter
         return this.state;
     }
 
-    private void negotiationSuccessful(final BGPSessionImpl session) {
+    @GuardedBy("this")
+    private void negotiationSuccessful() {
         LOG.debug("Negotiation on channel {} successful with session {}", this.channel, session);
         this.channel.pipeline().replace(this, "session", session);
         this.promise.setSuccess(session);
@@ -284,6 +286,7 @@ abstract class AbstractBGPSessionNegotiator extends ChannelInboundHandlerAdapter
     }
 
     @Override
+    @SuppressWarnings("checkstyle:illegalCatch")
     public final void channelRead(final ChannelHandlerContext ctx, final Object msg) {
         LOG.debug("Negotiation read invoked on channel {}", this.channel);
         try {