Removed some sonar warnings. 06/15606/3
authorDana Kutenicsova <dkutenic@cisco.com>
Sun, 22 Feb 2015 21:42:07 +0000 (22:42 +0100)
committerDana Kutenicsova <dkutenic@cisco.com>
Mon, 23 Feb 2015 11:38:08 +0000 (12:38 +0100)
Change-Id: I5f152d314c5021134f54f4c1b9ca2fc77d685d0f
Signed-off-by: Dana Kutenicsova <dkutenic@cisco.com>
bgp/flowspec/src/main/java/org/opendaylight/protocol/bgp/flowspec/FSNlriParser.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/PCEPPeerRegistry.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/message/PCEPMonitoringReplyMessageParser.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/message/PCEPReplyMessageParser.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/object/PCEPProcTimeObjectParser.java
pcep/segment-routing/src/main/java/org/opendaylight/protocol/pcep/segment/routing/SrSubobjectParserUtil.java
pcep/topology-spi/src/main/java/org/opendaylight/bgpcep/pcep/topology/spi/AbstractInstructionExecutor.java
pcep/tunnel-provider/src/main/java/org/opendaylight/bgpcep/pcep/tunnel/provider/TunnelProgramming.java

index 40d2c5d3a0fc7021c55faf882c503e78d6c2e338..4f5c372334b988394be89a2ed2148d3a366c16cf 100644 (file)
@@ -341,7 +341,7 @@ public class FSNlriParser implements NlriParser, NlriSerializer {
         // length field can be one or two bytes (if needed)
         // check the length of nlri to see how many bytes we can skip
         final int length = nlri.readableBytes();
-        nlri.skipBytes(length > 240 ? NLRI_LENGTH_EXTENDED : NLRI_LENGTH);
+        nlri.skipBytes(length > MAX_NLRI_LENGTH_ONE_BYTE ? NLRI_LENGTH_EXTENDED : NLRI_LENGTH);
 
         while(nlri.isReadable()) {
             final FlowspecBuilder builder = new FlowspecBuilder();
index 62639366dd5d5d78228843b0b5edc72fa6ae1453..dfb732b9dfad75b1e9b33a3ed691e74c442bad4f 100644 (file)
@@ -97,23 +97,23 @@ final class PCEPPeerRegistry {
         private final byte[] byteArray;
 
         public ByteArrayWrapper(final byte[] byteArray) {
-            this.byteArray = byteArray;
+            this.byteArray = byteArray == null ? null : byteArray.clone();
         }
 
         @Override
         public int hashCode() {
-            return Arrays.hashCode(byteArray);
+            return Arrays.hashCode(this.byteArray);
         }
 
         @Override
-        public boolean equals(Object obj) {
+        public boolean equals(final Object obj) {
             if (this == obj) {
                 return true;
             }
             if (!(obj instanceof ByteArrayWrapper)) {
                 return false;
             }
-            return Arrays.equals(byteArray, ((ByteArrayWrapper) obj).byteArray);
+            return Arrays.equals(this.byteArray, ((ByteArrayWrapper) obj).byteArray);
         }
     }
 }
index a5ee099e0f2f59d5cd23393c69ff4562f0f36769..f972100b250b3421e7680dea76346cc76816f9c8 100644 (file)
@@ -12,7 +12,6 @@ import com.google.common.base.Optional;
 import com.google.common.base.Preconditions;
 import io.netty.buffer.ByteBuf;
 import io.netty.buffer.Unpooled;
-
 import java.util.ArrayList;
 import java.util.List;
 import org.opendaylight.protocol.pcep.spi.AbstractMessageParser;
@@ -166,6 +165,8 @@ public class PCEPMonitoringReplyMessageParser extends AbstractMessageParser {
                 break;
             case END :
                 break;
+            default:
+                break;
             }
             if (!state.equals(State.END)) {
                 objects.remove(0);
index 2a6e48a6076254ba7d964e2cecf904e8ca2586a4..c6b9134eb3d21e7ecd1f71d8803024c584268158 100644 (file)
@@ -365,6 +365,8 @@ public class PCEPReplyMessageParser extends AbstractMessageParser {
                 break;
             case END :
                 break;
+            default:
+                break;
             }
             if (!state.equals(MetricPceState.END)) {
                 objects.remove(0);
index 20af2011627d28c5c43379a3f0eaeeb0fe0c5d2d..a9b6e0af06b5351d36d4a07f964bf95a48b6f609 100644 (file)
@@ -37,7 +37,8 @@ public class PCEPProcTimeObjectParser implements ObjectParser, ObjectSerializer
 
     private static final int RESERVED = 2;
     private static final int FLAGS = RESERVED;
-    private static final int BODY_SIZE = RESERVED + FLAGS + 5 * INT_BYTES_LENGTH;
+    private static final int COUNT_FIELDS = 5;
+    private static final int BODY_SIZE = RESERVED + FLAGS + COUNT_FIELDS * INT_BYTES_LENGTH;
     private static final int E_FLAG_POSITION = 15;
 
     @Override
index 7ed30391fd285484784371c25845b6c17e53b8c3..da03eecaffb8660e4a6c119980676d65c9175ff7 100644 (file)
@@ -37,7 +37,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.seg
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing.rev150112.sr.subobject.nai.UnnumberedAdjacencyBuilder;
 import org.opendaylight.yangtools.yang.binding.DataContainer;
 
-class SrSubobjectParserUtil {
+final class SrSubobjectParserUtil {
 
     public static final int MINIMAL_LENGTH = 4;
     public static final int BITSET_LENGTH = 8;
@@ -147,22 +147,18 @@ class SrSubobjectParserUtil {
         }
 
         return new SrSubobject() {
-
             @Override
             public Class<? extends DataContainer> getImplementedInterface() {
                 return SrSubobject.class;
             }
-
             @Override
             public SidType getSidType() {
                 return sidType;
             }
-
             @Override
             public Long getSid() {
                 return sid;
             }
-
             @Override
             public Nai getNai() {
                 return nai;
index a7b55bb56668cbb2c52a644bb400c0cfc7b75e63..69dcc41e13d1674fb435927a2c3b024c967cdb0c 100644 (file)
@@ -22,10 +22,41 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-/**
- *
- */
 public abstract class AbstractInstructionExecutor implements FutureCallback<Instruction> {
+
+    private static final class InstructionCallback implements FutureCallback<OperationResult> {
+
+        private final Instruction insn;
+
+        public InstructionCallback(final Instruction insn) {
+            this.insn = insn;
+        }
+
+        @Override
+        public void onSuccess(final OperationResult result) {
+            if (result.getFailure() != null) {
+                switch (result.getFailure()) {
+                case Failed:
+                case NoAck:
+                    this.insn.executionCompleted(InstructionStatus.Failed, null);
+                    break;
+                case Unsent:
+                    this.insn.executionCompleted(InstructionStatus.Cancelled, null);
+                    break;
+                default:
+                    break;
+                }
+            } else {
+                this.insn.executionCompleted(InstructionStatus.Successful, null);
+            }
+        }
+
+        @Override
+        public void onFailure(final Throwable t) {
+            this.insn.executionCompleted(InstructionStatus.Failed, null);
+        }
+    }
+
     private static final Logger LOG = LoggerFactory.getLogger(AbstractInstructionExecutor.class);
     private final SubmitInstructionInput input;
 
@@ -39,14 +70,12 @@ public abstract class AbstractInstructionExecutor implements FutureCallback<Inst
 
     public static FailureCase schedule(final InstructionScheduler scheduler, final AbstractInstructionExecutor fwd) {
         final ListenableFuture<Instruction> s;
-
         try {
             s = scheduler.scheduleInstruction(fwd.getInput());
         } catch (final SchedulerException e) {
             LOG.info("Instuction {} failed to schedule", e.getMessage(), e);
             return new FailureCaseBuilder().setFailure(e.getFailure()).build();
         }
-
         Futures.addCallback(s, fwd);
         return null;
     }
@@ -57,31 +86,7 @@ public abstract class AbstractInstructionExecutor implements FutureCallback<Inst
     public void onSuccess(final Instruction insn) {
         if (insn.checkedExecutionStart()) {
             final ListenableFuture<OperationResult> s = invokeOperation();
-            Futures.addCallback(s, new FutureCallback<OperationResult>() {
-                @Override
-                public void onSuccess(final OperationResult result) {
-                    if (result.getFailure() != null) {
-                        switch (result.getFailure()) {
-                        case Failed:
-                        case NoAck:
-                            insn.executionCompleted(InstructionStatus.Failed, null);
-                            break;
-                        case Unsent:
-                            insn.executionCompleted(InstructionStatus.Cancelled, null);
-                            break;
-                        default:
-                            break;
-                        }
-                    } else {
-                        insn.executionCompleted(InstructionStatus.Successful, null);
-                    }
-                }
-
-                @Override
-                public void onFailure(final Throwable t) {
-                    insn.executionCompleted(InstructionStatus.Failed, null);
-                }
-            });
+            Futures.addCallback(s, new InstructionCallback(insn));
         }
     }
 
index ede798d7207f4f608597d089c4ebdf2ca1cb1df7..fb1865dc57716896cd329598f47abd385f7e070b 100644 (file)
@@ -315,7 +315,7 @@ public final class TunnelProgramming implements TopologyTunnelPcepProgrammingSer
                         // The source node has to exist
                         node = sourceNode(t, tii, link).get();
                     } catch (IllegalStateException | ReadFailedException e) {
-                        LOG.debug("Link or node does not exist.", e.getMessage());
+                        LOG.debug("Link or node does not exist.", e);
                         return Futures.<OperationResult>immediateFuture(new OperationResult() {
                             @Override
                             public Class<? extends DataContainer> getImplementedInterface() {
@@ -375,7 +375,7 @@ public final class TunnelProgramming implements TopologyTunnelPcepProgrammingSer
                         // The source node has to exist
                         node = sourceNode(t, tii, link).get();
                     } catch (IllegalStateException | ReadFailedException e) {
-                        LOG.debug("Link or node does not exist.", e.getMessage());
+                        LOG.debug("Link or node does not exist.", e);
                         return Futures.<OperationResult>immediateFuture(new OperationResult() {
                             @Override
                             public Class<? extends DataContainer> getImplementedInterface() {