Fix checkstyle
[bgpcep.git] / pcep / impl / src / main / java / org / opendaylight / protocol / pcep / impl / PCEPProtocolSessionPromise.java
old mode 100755 (executable)
new mode 100644 (file)
index 5ebe880..c59f73a
@@ -32,43 +32,44 @@ public final class PCEPProtocolSessionPromise<S extends PCEPSession> extends Def
     private InetSocketAddress address;
     private final int retryTimer;
     private final int connectTimeout;
-    private final Bootstrap b;
+    private final Bootstrap bootstrap;
     @GuardedBy("this")
     private Future<?> pending;
 
     PCEPProtocolSessionPromise(final EventExecutor executor, final InetSocketAddress address,
-            final int retryTimer, final int connectTimeout, final Bootstrap b) {
+            final int retryTimer, final int connectTimeout, final Bootstrap bootstrap) {
         super(executor);
         this.address = requireNonNull(address);
         this.retryTimer = retryTimer;
         this.connectTimeout = connectTimeout;
-        this.b = requireNonNull(b);
+        this.bootstrap = requireNonNull(bootstrap);
     }
 
+    @SuppressWarnings("checkstyle:IllegalCatch")
     synchronized void connect() {
         final PCEPProtocolSessionPromise<?> lock = this;
 
         try {
-            LOG.debug("Promise {} attempting connect for {}ms", lock, this.connectTimeout);
-            if (this.address.isUnresolved()) {
-                this.address = new InetSocketAddress(this.address.getHostName(), this.address.getPort());
+            LOG.debug("Promise {} attempting connect for {}ms", lock, connectTimeout);
+            if (address.isUnresolved()) {
+                address = new InetSocketAddress(address.getHostName(), address.getPort());
             }
 
-            this.b.option(ChannelOption.CONNECT_TIMEOUT_MILLIS, this.connectTimeout);
-            this.b.remoteAddress(this.address);
-            final ChannelFuture connectFuture = this.b.connect();
+            bootstrap.option(ChannelOption.CONNECT_TIMEOUT_MILLIS, connectTimeout);
+            bootstrap.remoteAddress(address);
+            final ChannelFuture connectFuture = bootstrap.connect();
             connectFuture.addListener(new BootstrapConnectListener());
-            this.pending = connectFuture;
-        } catch (Exception e) {
-            LOG.info("Failed to connect to {}", this.address, e);
-            this.setFailure(e);
+            pending = connectFuture;
+        } catch (RuntimeException e) {
+            LOG.info("Failed to connect to {}", address, e);
+            setFailure(e);
         }
     }
 
     @Override
     public synchronized boolean cancel(final boolean mayInterruptIfRunning) {
         if (super.cancel(mayInterruptIfRunning)) {
-            this.pending.cancel(mayInterruptIfRunning);
+            pending.cancel(mayInterruptIfRunning);
             return true;
         }
 
@@ -81,14 +82,14 @@ public final class PCEPProtocolSessionPromise<S extends PCEPSession> extends Def
         return super.setSuccess(result);
     }
 
-    private class BootstrapConnectListener implements ChannelFutureListener {
+    private final class BootstrapConnectListener implements ChannelFutureListener {
         @Override
         public void operationComplete(final ChannelFuture cf) {
             synchronized (PCEPProtocolSessionPromise.this) {
                 PCEPProtocolSessionPromise.LOG.debug("Promise {} connection resolved",
                         PCEPProtocolSessionPromise.this);
                 Preconditions.checkState(PCEPProtocolSessionPromise.this.pending.equals(cf));
-                if (PCEPProtocolSessionPromise.this.isCancelled()) {
+                if (isCancelled()) {
                     if (cf.isSuccess()) {
                         PCEPProtocolSessionPromise.LOG.debug("Closing channel for cancelled promise {}",
                                 PCEPProtocolSessionPromise.this);
@@ -104,7 +105,7 @@ public final class PCEPProtocolSessionPromise<S extends PCEPSession> extends Def
                     if (PCEPProtocolSessionPromise.this.retryTimer == 0) {
                         PCEPProtocolSessionPromise.LOG
                                 .debug("Retry timer value is 0. Reconnection will not be attempted");
-                        PCEPProtocolSessionPromise.this.setFailure(cf.cause());
+                        setFailure(cf.cause());
                         return;
                     }
 
@@ -113,7 +114,7 @@ public final class PCEPProtocolSessionPromise<S extends PCEPSession> extends Def
                         synchronized (PCEPProtocolSessionPromise.this) {
                             PCEPProtocolSessionPromise.LOG.debug("Attempting to connect to {}",
                                     PCEPProtocolSessionPromise.this.address);
-                            final Future<Void> reconnectFuture = PCEPProtocolSessionPromise.this.b.connect();
+                            final Future<Void> reconnectFuture = PCEPProtocolSessionPromise.this.bootstrap.connect();
                             reconnectFuture.addListener(BootstrapConnectListener.this);
                             PCEPProtocolSessionPromise.this.pending = reconnectFuture;
                         }