BUG-2208: Add missing return on PCCDispatcherImpl 88/32288/5
authorClaudio D. Gasparini <cgaspari@cisco.com>
Fri, 8 Jan 2016 12:51:57 +0000 (13:51 +0100)
committerMilos Fabian <milfabia@cisco.com>
Mon, 11 Jan 2016 00:58:01 +0000 (00:58 +0000)
Change-Id: Ie9ff5d9ce8ab54ed9682ddc9da48eba7d7534cc8
Signed-off-by: Claudio D. Gasparini <cgaspari@cisco.com>
pcep/pcc-mock/src/main/java/org/opendaylight/protocol/pcep/pcc/mock/PCCDispatcherImpl.java

index 05a6d16988c9d7eba72fce4825396752d78ad2ab..5e1f10e84975cb290f846f596e9afa318712f39b 100644 (file)
@@ -85,16 +85,16 @@ public final class PCCDispatcherImpl implements PccDispatcher, AutoCloseable {
 
     @Override
     public Future<PCEPSession> createClient(
-            final InetSocketAddress remoteAddress, final long reconnectTime, final PCEPSessionListenerFactory listenerFactory,
-            final PCEPSessionNegotiatorFactory negotiatorFactory, final KeyMapping keys, final InetSocketAddress localAddress) {
+        final InetSocketAddress remoteAddress, final long reconnectTime, final PCEPSessionListenerFactory listenerFactory,
+        final PCEPSessionNegotiatorFactory negotiatorFactory, final KeyMapping keys, final InetSocketAddress localAddress) {
         final Bootstrap b = new Bootstrap();
         b.group(this.workerGroup);
         b.localAddress(localAddress);
         setChannelFactory(b, keys);
         b.option(ChannelOption.SO_KEEPALIVE, true);
         b.option(ChannelOption.MAX_MESSAGES_PER_READ, 1);
-        final PCCReconnectPromise promise = new PCCReconnectPromise(remoteAddress,
-                reconnectTime == -1 ? getNeverReconnectStrategyFactory() : getTimedReconnectStrategyFactory(reconnectTime), b);
+        final ReconnectStrategyFactory reconnectStrategy = reconnectTime == -1 ? getNeverReconnectStrategyFactory() : getTimedReconnectStrategyFactory(reconnectTime);
+        final PCCReconnectPromise promise = new PCCReconnectPromise(remoteAddress, reconnectStrategy, b);
         final ChannelInitializer<SocketChannel> channelInitializer = new ChannelInitializer<SocketChannel>() {
             @Override
             protected void initChannel(final SocketChannel ch) throws Exception {
@@ -110,10 +110,11 @@ public final class PCCDispatcherImpl implements PccDispatcher, AutoCloseable {
 
                         if (!promise.isInitialConnectFinished()) {
                             LOG.debug("Connection to {} was dropped during negotiation, reattempting", remoteAddress);
+                            return;
                         }
                         LOG.debug("Reconnecting after connection to {} was dropped", remoteAddress);
                         PCCDispatcherImpl.this.createClient(remoteAddress, reconnectTime, listenerFactory, negotiatorFactory,
-                                keys, localAddress);
+                            keys, localAddress);
                     }
                 });
             }