BUG-731 : removed critical sonar warnings 60/11760/2
authorDana Kutenicsova <dkutenic@cisco.com>
Fri, 10 Oct 2014 08:40:16 +0000 (10:40 +0200)
committerDana Kutenicsova <dkutenic@cisco.com>
Fri, 10 Oct 2014 08:40:16 +0000 (10:40 +0200)
Change-Id: Ic213c01c1c2ecbab3e4cd7cb7a6167713fe94a8c
Signed-off-by: Dana Kutenicsova <dkutenic@cisco.com>
bgp/linkstate/src/main/java/org/opendaylight/protocol/bgp/linkstate/LinkstateAdjRIBsIn.java
bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/BGPSessionImpl.java
pcep/segment-routing/src/main/java/org/opendaylight/protocol/pcep/lsp/setup/type01/CInitiated00SrpObjectWithPstTlvParser.java
pcep/segment-routing/src/main/java/org/opendaylight/protocol/pcep/lsp/setup/type01/PcepRpObjectWithPstTlvParser.java
pcep/topology-provider/src/main/java/org/opendaylight/bgpcep/pcep/topology/provider/AbstractTopologySessionListener.java
pcep/topology-provider/src/main/java/org/opendaylight/bgpcep/pcep/topology/provider/ServerSessionManager.java

index 80df0203c2dbd37e90a5ec84c87d03c934f90369..47cc5b2a3a6bc13302a88eb52e2a265c8ebba90b 100644 (file)
@@ -300,6 +300,7 @@ final class LinkstateAdjRIBsIn extends AbstractAdjRIBs<CLinkstateDestination, Li
         }
         if (dests == null || dests.size() != 1) {
             LOG.warn("Null or more than one LinkstateRoute Key was parsed");
+            return null;
         }
         return dests.get(0);
     }
index 005dc368d5a2ca00bff36a8cb21892eb6bec2b78..c7837329a29bef549ff83715c2c8cf7d1543b994 100644 (file)
@@ -331,7 +331,7 @@ public class BGPSessionImpl extends AbstractProtocolSession<Notification> implem
     }
 
     @VisibleForTesting
-    protected void setLastMessageSentAt(final long lastMessageSentAt) {
+    protected synchronized void setLastMessageSentAt(final long lastMessageSentAt) {
         this.lastMessageSentAt = lastMessageSentAt;
     }
 }
index 01c7d41936c4809830766fc57c8366240e952159..7d4f13700a3c646b837f6216cac8543cd10288fb 100644 (file)
@@ -32,11 +32,9 @@ public class CInitiated00SrpObjectWithPstTlvParser extends CInitiated00SrpObject
     public void addTlv(final TlvsBuilder builder, final Tlv tlv) {
         super.addTlv(builder, tlv);
         final Tlvs7Builder tlvBuilder = new Tlvs7Builder();
-        if (builder != null) {
-            final Tlvs7 tlvs = builder.getAugmentation(Tlvs7.class);
-            if (tlvs != null && tlvs.getPathSetupType() != null) {
-                tlvBuilder.setPathSetupType(tlvs.getPathSetupType());
-            }
+        final Tlvs7 tlvs = builder.getAugmentation(Tlvs7.class);
+        if (tlvs != null && tlvs.getPathSetupType() != null) {
+            tlvBuilder.setPathSetupType(tlvs.getPathSetupType());
         }
         if (tlv instanceof PathSetupType) {
             tlvBuilder.setPathSetupType((PathSetupType) tlv);
index f6393ba9d05b357ccebdb93b056b1f835bf227c5..2c161141b30567f88d1e61d0788be6af606cf1ba 100644 (file)
@@ -24,19 +24,17 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.typ
 
 public class PcepRpObjectWithPstTlvParser extends PCEPRequestParameterObjectParser {
 
-    public PcepRpObjectWithPstTlvParser(TlvRegistry tlvReg, VendorInformationTlvRegistry viTlvReg) {
+    public PcepRpObjectWithPstTlvParser(final TlvRegistry tlvReg, final VendorInformationTlvRegistry viTlvReg) {
         super(tlvReg, viTlvReg);
     }
 
     @Override
-    public void addTlv(final TlvsBuilder builder, Tlv tlv) {
+    public void addTlv(final TlvsBuilder builder, final Tlv tlv) {
         super.addTlv(builder, tlv);
         final Tlvs1Builder tlvBuilder = new Tlvs1Builder();
-        if (builder != null) {
-            final Tlvs1 tlvs = builder.getAugmentation(Tlvs1.class);
-            if (tlvs != null && tlvs.getPathSetupType() != null) {
-                tlvBuilder.setPathSetupType(tlvs.getPathSetupType());
-            }
+        final Tlvs1 tlvs = builder.getAugmentation(Tlvs1.class);
+        if (tlvs != null && tlvs.getPathSetupType() != null) {
+            tlvBuilder.setPathSetupType(tlvs.getPathSetupType());
         }
         if (tlv instanceof PathSetupType) {
             tlvBuilder.setPathSetupType((PathSetupType) tlv);
index 0fc3f2c56f845717c7b01996703fc52250ccb3f9..46ad4cab9cbbc18830ecf96358e11e9dcc149d37 100644 (file)
@@ -12,9 +12,7 @@ import com.google.common.base.Preconditions;
 import com.google.common.util.concurrent.FutureCallback;
 import com.google.common.util.concurrent.Futures;
 import com.google.common.util.concurrent.ListenableFuture;
-
 import io.netty.util.concurrent.FutureListener;
-
 import java.net.InetAddress;
 import java.util.ArrayList;
 import java.util.Collection;
@@ -22,9 +20,7 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.Map.Entry;
-
 import javax.annotation.concurrent.GuardedBy;
-
 import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
 import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
@@ -128,11 +124,7 @@ public abstract class AbstractTopologySessionListener<S, L> implements PCEPSessi
          */
         final InetAddress peerAddress = session.getRemoteAddress();
 
-        final TopologyNodeState state = serverSessionManager.takeNodeState(peerAddress, this);
-        if (state == null) {
-            session.close(TerminationReason.Unknown);
-            return;
-        }
+        final TopologyNodeState state = this.serverSessionManager.takeNodeState(peerAddress, this);
 
         LOG.trace("Peer {} resolved to topology node {}", peerAddress, state.getNodeId());
         this.synced = false;
@@ -172,7 +164,7 @@ public abstract class AbstractTopologySessionListener<S, L> implements PCEPSessi
 
     @GuardedBy("this")
     private void tearDown(final PCEPSession session) {
-        this.serverSessionManager.releaseNodeState(this.nodeState);
+        this.serverSessionManager.releaseNodeState(this.nodeState, session);
         this.nodeState = null;
         this.session = null;
 
@@ -344,7 +336,6 @@ public abstract class AbstractTopologySessionListener<S, L> implements PCEPSessi
             LOG.debug("Setting new paths {} to lsp {}", updatedPaths, name);
             rlb.setPath(updatedPaths);
         }
-        Preconditions.checkState(name != null);
         rlb.setKey(new ReportedLspKey(name));
         rlb.setName(name);
 
@@ -415,7 +406,7 @@ public abstract class AbstractTopologySessionListener<S, L> implements PCEPSessi
         return this.lsps.get(id);
     }
 
-    protected synchronized final <T extends DataObject> ListenableFuture<Optional<T>> readOperationalData(final InstanceIdentifier<T> id) {
+    protected final synchronized <T extends DataObject> ListenableFuture<Optional<T>> readOperationalData(final InstanceIdentifier<T> id) {
         return this.nodeState.readOperationalData(id);
     }
 }
index 9897ba3f4289c928f4a4d2d6d67b62a2f9871a1f..afc7172f89ee03f5af6a32431cdc4aec6eb8217a 100644 (file)
@@ -22,6 +22,7 @@ import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
 import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
 import org.opendaylight.protocol.framework.SessionListenerFactory;
+import org.opendaylight.protocol.pcep.PCEPSession;
 import org.opendaylight.protocol.pcep.PCEPSessionListener;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev131024.AddLspArgs;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev131024.EnsureLspOperationalInput;
@@ -84,9 +85,9 @@ final class ServerSessionManager implements SessionListenerFactory<PCEPSessionLi
         return new NodeId("pcc://" + addr.getHostAddress());
     }
 
-    synchronized void releaseNodeState(final TopologyNodeState nodeState) {
+    synchronized void releaseNodeState(final TopologyNodeState nodeState, final PCEPSession session) {
         LOG.debug("Node {} unbound", nodeState.getNodeId());
-        this.nodes.remove(nodeState.getNodeId());
+        this.nodes.remove(createNodeId(session.getRemoteAddress()));
         nodeState.released();
     }
 
@@ -97,12 +98,11 @@ final class ServerSessionManager implements SessionListenerFactory<PCEPSessionLi
         TopologyNodeState ret = this.state.get(id);
 
         if (ret == null) {
-            ret = new TopologyNodeState(broker, topology, id, DEFAULT_HOLD_STATE_NANOS);
+            ret = new TopologyNodeState(this.broker, this.topology, id, DEFAULT_HOLD_STATE_NANOS);
             LOG.debug("Created topology node {} for id {} at {}", ret, id, ret.getNodeId());
             this.state.put(id, ret);
-        } else {
-            // FIXME: check for conflicting session
         }
+        // FIXME: else check for conflicting session
 
         ret.taken();
         this.nodes.put(id, sessionListener);
@@ -112,7 +112,7 @@ final class ServerSessionManager implements SessionListenerFactory<PCEPSessionLi
 
     @Override
     public PCEPSessionListener getSessionListener() {
-        return listenerFactory.createTopologySessionListener(this);
+        return this.listenerFactory.createTopologySessionListener(this);
     }
 
     @Override
@@ -165,10 +165,10 @@ final class ServerSessionManager implements SessionListenerFactory<PCEPSessionLi
 
     @Override
     public void close() throws TransactionCommitFailedException {
-        for (final TopologySessionListener sessionListener : nodes.values()) {
+        for (final TopologySessionListener sessionListener : this.nodes.values()) {
             sessionListener.close();
         }
-        for (final TopologyNodeState nodeState : state.values()) {
+        for (final TopologyNodeState nodeState : this.state.values()) {
             nodeState.close();
         }
         final WriteTransaction t = this.broker.newWriteOnlyTransaction();