Fixed various small bugs found by Findbugs plugin. 35/9335/3
authorDana Kutenicsova <dkutenic@cisco.com>
Fri, 25 Jul 2014 21:27:46 +0000 (23:27 +0200)
committerDana Kutenicsova <dkutenic@cisco.com>
Fri, 25 Jul 2014 22:21:38 +0000 (00:21 +0200)
Change-Id: I343625bdb9efd2c0ffdfc12f6c0c9119f377041c
Signed-off-by: Dana Kutenicsova <dkutenic@cisco.com>
14 files changed:
bgp/parser-spi/src/main/java/org/opendaylight/protocol/bgp/parser/spi/pojo/SimpleNlriRegistry.java
bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/AbstractBGPSessionNegotiator.java
bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/BGPSessionImpl.java
bgp/util/src/main/java/org/opendaylight/protocol/bgp/util/HexDumpBGPFileParser.java
pcep/ietf-stateful02/src/main/java/org/opendaylight/protocol/pcep/ietf/stateful02/Stateful02PCRequestMessageParser.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/message/PCEPRequestMessageParser.java
pcep/topology-provider/src/main/java/org/opendaylight/bgpcep/pcep/topology/provider/Stateful02TopologySessionListener.java
pcep/topology-provider/src/main/java/org/opendaylight/bgpcep/pcep/topology/provider/Stateful07TopologySessionListener.java
pcep/topology-provider/src/test/java/org/opendaylight/bgpcep/pcep/topology/provider/ParserToSalTest.java
pcep/tunnel-provider/src/main/java/org/opendaylight/bgpcep/pcep/tunnel/provider/NodeChangedListener.java
programming/impl/src/main/java/org/opendaylight/bgpcep/programming/impl/InstructionImpl.java
programming/impl/src/main/java/org/opendaylight/bgpcep/programming/impl/ProgrammingServiceImpl.java
util/src/main/java/org/opendaylight/protocol/util/ByteArray.java
util/src/main/java/org/opendaylight/protocol/util/PCEPHexDumpParser.java

index 73d5ff6c6a3173ed8354a76552276d061e0ad205..40b6c2e457fc26b975f62e52b810e54543ec0030 100644 (file)
@@ -57,7 +57,7 @@ final class SimpleNlriRegistry implements NlriRegistry {
     }
 
     synchronized AutoCloseable registerNlriSerializer(final Class<? extends DataObject> nlriClass, final NlriSerializer serializer){
-        final NlriParser prev = this.handlers.get(nlriClass);
+        final NlriSerializer prev = this.serializers.get(nlriClass);
         Preconditions.checkState(prev == null, "Serializer already bound to class " + prev);
 
         this.serializers.put(nlriClass, serializer);
index 5bf1f7ade26761458ec895f28ed72bcabbfb06d1..d99872f27cfd5c4ee0853b1e5ee734e11a89ee62 100644 (file)
@@ -90,7 +90,7 @@ public abstract class AbstractBGPSessionNegotiator extends AbstractSessionNegoti
     }
 
     @Override
-    protected void startNegotiation() {
+    protected synchronized void startNegotiation() {
         Preconditions.checkState(this.state == State.Idle);
 
         // Check if peer is configured in registry before retrieving preferences
index beb1489d94f63cac2e203d7dd98926592515aea8..7ef25879f3e715700921f436f0f9f286e95ebe82 100644 (file)
@@ -12,16 +12,12 @@ import com.google.common.base.Objects;
 import com.google.common.base.Objects.ToStringHelper;
 import com.google.common.base.Preconditions;
 import com.google.common.collect.Sets;
-
 import io.netty.channel.Channel;
-
 import java.io.IOException;
 import java.util.Date;
 import java.util.Set;
 import java.util.concurrent.TimeUnit;
-
 import javax.annotation.concurrent.GuardedBy;
-
 import org.opendaylight.protocol.bgp.parser.AsNumberUtil;
 import org.opendaylight.protocol.bgp.parser.BGPError;
 import org.opendaylight.protocol.bgp.parser.BGPSession;
@@ -284,7 +280,7 @@ public class BGPSessionImpl extends AbstractProtocolSession<Notification> implem
 
     protected ToStringHelper addToStringAttributes(final ToStringHelper toStringHelper) {
         toStringHelper.add("channel", this.channel);
-        toStringHelper.add("state", this.state);
+        toStringHelper.add("state", this.getState());
         return toStringHelper;
     }
 
index 432a9a88b76f52b06a987c1b011b11df3507ddb1..4af24345fe03bb884f726a2fffc35e27933a9246 100644 (file)
@@ -12,16 +12,13 @@ import com.google.common.base.Preconditions;
 import com.google.common.base.Strings;
 import com.google.common.collect.Lists;
 import com.google.common.io.CharStreams;
-
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.InputStreamReader;
 import java.util.List;
-
 import javax.annotation.concurrent.Immutable;
-
 import org.apache.commons.codec.DecoderException;
 import org.apache.commons.codec.binary.Hex;
 import org.opendaylight.protocol.util.ByteArray;
@@ -87,7 +84,7 @@ public final class HexDumpBGPFileParser {
             try {
                 message = Hex.decodeHex(hexMessage.toCharArray());
             } catch (final DecoderException e) {
-                new IllegalArgumentException("Failed to decode message body", e);
+                throw new IllegalArgumentException("Failed to decode message body", e);
             }
             messages.add(message);
             idx = messageEndIdx;
index 09ce406ad69a1fbd0256e2ff28b53a72820927c9..afbd0e6e1882db993abf4c20fe3bf78220148229 100644 (file)
@@ -8,11 +8,8 @@
 package org.opendaylight.protocol.pcep.ietf.stateful02;
 
 import com.google.common.collect.Lists;
-
 import io.netty.buffer.ByteBuf;
-
 import java.util.List;
-
 import org.opendaylight.protocol.pcep.impl.message.PCEPRequestMessageParser;
 import org.opendaylight.protocol.pcep.spi.ObjectRegistry;
 import org.opendaylight.protocol.pcep.spi.PCEPErrors;
@@ -22,7 +19,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.cra
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Object;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.bandwidth.object.Bandwidth;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.bandwidth.object.BandwidthBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.classtype.object.ClassType;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.exclude.route.object.Xro;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.include.route.object.Iro;
@@ -202,9 +198,8 @@ public final class Stateful02PCRequestMessageParser extends PCEPRequestMessagePa
 
         if (rp.isReoptimization()
                 && builder.getBandwidth() != null
-                && builder.getReportedRoute().getBandwidth().getBandwidth() != new BandwidthBuilder().setBandwidth(
-                        new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.network.concepts.rev131125.Bandwidth(new byte[] { 0 })).build()
-                        && builder.getReportedRoute().getRro() == null) {
+                && builder.getReportedRoute().getBandwidth().getBandwidth() != new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.network.concepts.rev131125.Bandwidth(new byte[] { 0 })
+                && builder.getReportedRoute().getRro() == null) {
             errors.add(createErrorMsg(PCEPErrors.RRO_MISSING, rp));
             return null;
         }
index 7fe6ab6fa97f4aafac5d4a89c374f073a6575c32..924cffc81dd1d992fd0f010a8b067dce3f79dfc1 100644 (file)
@@ -9,12 +9,9 @@ package org.opendaylight.protocol.pcep.impl.message;
 
 import com.google.common.base.Preconditions;
 import com.google.common.collect.Lists;
-
 import io.netty.buffer.ByteBuf;
 import io.netty.buffer.Unpooled;
-
 import java.util.List;
-
 import org.opendaylight.protocol.pcep.spi.AbstractMessageParser;
 import org.opendaylight.protocol.pcep.spi.MessageUtil;
 import org.opendaylight.protocol.pcep.spi.ObjectRegistry;
@@ -25,7 +22,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.mes
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Object;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.bandwidth.object.Bandwidth;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.bandwidth.object.BandwidthBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.classtype.object.ClassType;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.endpoints.object.EndpointsObj;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.exclude.route.object.Xro;
@@ -72,7 +68,7 @@ public class PCEPRequestMessageParser extends AbstractMessageParser {
         if (msg.getRequests() == null || msg.getRequests().isEmpty()) {
             throw new IllegalArgumentException("Requests cannot be null or empty.");
         }
-        ByteBuf buffer = Unpooled.buffer();
+        final ByteBuf buffer = Unpooled.buffer();
         for (final Requests req : msg.getRequests()) {
             serializeObject(req.getRp(), buffer);
             if (req.getPathKeyExpansion() != null) {
@@ -323,9 +319,9 @@ public class PCEPRequestMessageParser extends AbstractMessageParser {
 
         if (rp.isReoptimization()
                 && builder.getBandwidth() != null
-                && builder.getReportedRoute().getBandwidth().getBandwidth() != new BandwidthBuilder().setBandwidth(
-                        new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.network.concepts.rev131125.Bandwidth(new byte[] { 0 })).build()
-                        && builder.getReportedRoute().getRro() == null) {
+                && builder.getReportedRoute().getBandwidth().getBandwidth() !=
+                new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.network.concepts.rev131125.Bandwidth(new byte[] { 0 })
+                && builder.getReportedRoute().getRro() == null) {
             errors.add(createErrorMsg(PCEPErrors.RRO_MISSING, rp));
             return null;
         }
index 7eb3dee1e2aa64c289f1ef9d61caf84ad5f5b5eb..002c194a6b10ddce8e264ddf9d88f3994f9b8076 100644 (file)
@@ -15,13 +15,10 @@ import com.google.common.collect.ImmutableList;
 import com.google.common.util.concurrent.AsyncFunction;
 import com.google.common.util.concurrent.Futures;
 import com.google.common.util.concurrent.ListenableFuture;
-
 import java.net.InetAddress;
 import java.nio.ByteBuffer;
 import java.util.Collections;
-
 import javax.annotation.concurrent.GuardedBy;
-
 import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
 import org.opendaylight.protocol.pcep.PCEPSession;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.initiated._00.rev140113.PcinitiateBuilder;
@@ -128,7 +125,7 @@ public class Stateful02TopologySessionListener extends AbstractTopologySessionLi
 
             final ReportedLspBuilder rlb = new ReportedLspBuilder();
             rlb.addAugmentation(ReportedLsp1.class, new ReportedLsp1Builder().setLsp(lsp).build());
-            org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev131024.pcep.client.attributes.path.computation.client.reported.lsp.PathBuilder pb = new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev131024.pcep.client.attributes.path.computation.client.reported.lsp.PathBuilder();
+            final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev131024.pcep.client.attributes.path.computation.client.reported.lsp.PathBuilder pb = new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev131024.pcep.client.attributes.path.computation.client.reported.lsp.PathBuilder();
             if (r.getPath() != null) {
                 pb.fieldsFrom(r.getPath());
             }
@@ -169,7 +166,7 @@ public class Stateful02TopologySessionListener extends AbstractTopologySessionLi
 
     @Override
     public synchronized ListenableFuture<OperationResult> addLsp(final AddLspArgs input) {
-        Preconditions.checkArgument(input != null && input.getName() != null & input.getNode() != null && input.getArguments() != null, "Mandatory XML tags are missing.");
+        Preconditions.checkArgument(input != null && input.getName() != null && input.getNode() != null && input.getArguments() != null, "Mandatory XML tags are missing.");
         // Make sure there is no such LSP
         final InstanceIdentifier<ReportedLsp> lsp = lspIdentifier(input.getName()).build();
         final ListenableFuture<Optional<ReportedLsp>> f = readOperationalData(lsp);
@@ -205,7 +202,7 @@ public class Stateful02TopologySessionListener extends AbstractTopologySessionLi
 
     @Override
     public synchronized ListenableFuture<OperationResult> removeLsp(final RemoveLspArgs input) {
-        Preconditions.checkArgument(input != null && input.getName() != null & input.getNode() != null, "Mandatory XML tags are missing.");
+        Preconditions.checkArgument(input != null && input.getName() != null && input.getNode() != null, "Mandatory XML tags are missing.");
         // Make sure the LSP exists, we need it for PLSP-ID
         final InstanceIdentifier<ReportedLsp> lsp = lspIdentifier(input.getName()).build();
         final ListenableFuture<Optional<ReportedLsp>> f = readOperationalData(lsp);
@@ -220,7 +217,7 @@ public class Stateful02TopologySessionListener extends AbstractTopologySessionLi
 
                 final ReportedLsp1 ra = rep.get().getAugmentation(ReportedLsp1.class);
                 Preconditions.checkState(ra != null, "Reported LSP reported null from data-store.");
-                Lsp reportedLsp = ra.getLsp();
+                final Lsp reportedLsp = ra.getLsp();
                 Preconditions.checkState(reportedLsp != null, "Reported LSP does not contain LSP object.");
 
                 // Build the request and send it
@@ -236,7 +233,7 @@ public class Stateful02TopologySessionListener extends AbstractTopologySessionLi
 
     @Override
     public synchronized ListenableFuture<OperationResult> updateLsp(final UpdateLspArgs input) {
-        Preconditions.checkArgument(input != null && input.getName() != null & input.getNode() != null && input.getArguments() != null, "Mandatory XML tags are missing.");
+        Preconditions.checkArgument(input != null && input.getName() != null && input.getNode() != null && input.getArguments() != null, "Mandatory XML tags are missing.");
         // Make sure the LSP exists
         final InstanceIdentifier<ReportedLsp> lsp = lspIdentifier(input.getName()).build();
         final ListenableFuture<Optional<ReportedLsp>> f = readOperationalData(lsp);
@@ -251,9 +248,9 @@ public class Stateful02TopologySessionListener extends AbstractTopologySessionLi
 
                 final ReportedLsp1 ra = rep.get().getAugmentation(ReportedLsp1.class);
                 Preconditions.checkState(ra != null, "Reported LSP reported null from data-store.");
-                Lsp reportedLsp = ra.getLsp();
+                final Lsp reportedLsp = ra.getLsp();
                 Preconditions.checkState(reportedLsp != null, "Reported LSP does not contain LSP object.");
-                Arguments2 args = input.getArguments().getAugmentation(Arguments2.class);
+                final Arguments2 args = input.getArguments().getAugmentation(Arguments2.class);
                 Preconditions.checkArgument(args != null, "Input is missing operational tag.");
                 Preconditions.checkArgument(input.getArguments().getEro() != null, "Input is missing ERO object.");
 
@@ -272,7 +269,7 @@ public class Stateful02TopologySessionListener extends AbstractTopologySessionLi
 
     @Override
     public synchronized ListenableFuture<OperationResult> ensureLspOperational(final EnsureLspOperationalInput input) {
-        Preconditions.checkArgument(input != null && input.getName() != null & input.getNode() != null && input.getArguments() != null, "Mandatory XML tags are missing.");
+        Preconditions.checkArgument(input != null && input.getName() != null && input.getNode() != null && input.getArguments() != null, "Mandatory XML tags are missing.");
         final Boolean op;
         final Arguments1 aa = input.getArguments().getAugmentation(Arguments1.class);
         if (aa == null) {
@@ -300,7 +297,7 @@ public class Stateful02TopologySessionListener extends AbstractTopologySessionLi
                     LOG.warn("Node {} LSP {} does not contain data", input.getNode(), input.getName());
                     return OperationResults.UNSENT;
                 }
-                Lsp reportedLsp = ra.getLsp();
+                final Lsp reportedLsp = ra.getLsp();
                 Preconditions.checkState(reportedLsp != null, "Reported LSP does not contain LSP object.");
                 if (reportedLsp.isOperational().equals(op)) {
                     return OperationResults.SUCCESS;
index 911db95ed1abbbe38fa5f1d3757383c077f751c9..a3bd7c0f61ecbb566f4a7ade69e72f1d0a3c3377 100644 (file)
@@ -214,7 +214,7 @@ final class Stateful07TopologySessionListener extends AbstractTopologySessionLis
 
     @Override
     public synchronized ListenableFuture<OperationResult> addLsp(final AddLspArgs input) {
-        Preconditions.checkArgument(input != null && input.getName() != null & input.getNode() != null && input.getArguments() != null, "Mandatory XML tags are missing.");
+        Preconditions.checkArgument(input != null && input.getName() != null && input.getNode() != null && input.getArguments() != null, "Mandatory XML tags are missing.");
         LOG.trace("AddLspArgs {}", input);
         // Make sure there is no such LSP
         final InstanceIdentifier<ReportedLsp> lsp = lspIdentifier(input.getName()).build();
@@ -230,14 +230,14 @@ final class Stateful07TopologySessionListener extends AbstractTopologySessionLis
 
                 // Build the request
                 final RequestsBuilder rb = new RequestsBuilder();
-                Arguments2 args = input.getArguments().getAugmentation(Arguments2.class);
+                final Arguments2 args = input.getArguments().getAugmentation(Arguments2.class);
                 Preconditions.checkArgument(args != null, "Input is missing operational tag.");
-                Lsp inputLsp = args.getLsp();
+                final Lsp inputLsp = args.getLsp();
                 Preconditions.checkArgument(inputLsp != null, "Reported LSP does not contain LSP object.");
 
                 rb.fieldsFrom(input.getArguments());
 
-                TlvsBuilder tlvsBuilder = new TlvsBuilder();
+                final TlvsBuilder tlvsBuilder = new TlvsBuilder();
                 tlvsBuilder.setSymbolicPathName(
                         new SymbolicPathNameBuilder().setPathName(new SymbolicPathName(input.getName().getBytes(Charsets.UTF_8))).build());
                 if (inputLsp.getTlvs() != null) {
@@ -260,7 +260,7 @@ final class Stateful07TopologySessionListener extends AbstractTopologySessionLis
 
     @Override
     public synchronized ListenableFuture<OperationResult> removeLsp(final RemoveLspArgs input) {
-        Preconditions.checkArgument(input != null && input.getName() != null & input.getNode() != null, "Mandatory XML tags are missing.");
+        Preconditions.checkArgument(input != null && input.getName() != null && input.getNode() != null, "Mandatory XML tags are missing.");
         LOG.trace("RemoveLspArgs {}", input);
         // Make sure the LSP exists, we need it for PLSP-ID
         final InstanceIdentifier<ReportedLsp> lsp = lspIdentifier(input.getName()).build();
@@ -277,7 +277,7 @@ final class Stateful07TopologySessionListener extends AbstractTopologySessionLis
                 // it doesn't matter how many lsps there are in the path list, we only need delegate & plspid that is the same in each path
                 final Path1 ra = rep.get().getPath().get(0).getAugmentation(Path1.class);
                 Preconditions.checkState(ra != null, "Reported LSP reported null from data-store.");
-                Lsp reportedLsp = ra.getLsp();
+                final Lsp reportedLsp = ra.getLsp();
                 Preconditions.checkState(reportedLsp != null, "Reported LSP does not contain LSP object.");
 
                 // Build the request and send it
@@ -294,7 +294,7 @@ final class Stateful07TopologySessionListener extends AbstractTopologySessionLis
 
     @Override
     public synchronized ListenableFuture<OperationResult> updateLsp(final UpdateLspArgs input) {
-        Preconditions.checkArgument(input != null && input.getName() != null & input.getNode() != null && input.getArguments() != null, "Mandatory XML tags are missing.");
+        Preconditions.checkArgument(input != null && input.getName() != null && input.getNode() != null && input.getArguments() != null, "Mandatory XML tags are missing.");
         LOG.trace("UpdateLspArgs {}", input);
         // Make sure the LSP exists
         final InstanceIdentifier<ReportedLsp> lsp = lspIdentifier(input.getName()).build();
@@ -311,13 +311,13 @@ final class Stateful07TopologySessionListener extends AbstractTopologySessionLis
                 // it doesn't matter how many lsps there are in the path list, we only need plspid that is the same in each path
                 final Path1 ra = rep.get().getPath().get(0).getAugmentation(Path1.class);
                 Preconditions.checkState(ra != null, "Reported LSP reported null from data-store.");
-                Lsp reportedLsp = ra.getLsp();
+                final Lsp reportedLsp = ra.getLsp();
                 Preconditions.checkState(reportedLsp != null, "Reported LSP does not contain LSP object.");
 
                 // Build the PCUpd request and send it
                 final UpdatesBuilder rb = new UpdatesBuilder();
                 rb.setSrp(new SrpBuilder().setOperationId(nextRequest()).setProcessingRule(Boolean.TRUE).build());
-                Lsp inputLsp = input.getArguments().getAugmentation(Arguments3.class).getLsp();
+                final Lsp inputLsp = input.getArguments().getAugmentation(Arguments3.class).getLsp();
                 if (inputLsp != null) {
                     rb.setLsp(new LspBuilder().setPlspId(reportedLsp.getPlspId()).setDelegate((inputLsp.isDelegate() != null) ? inputLsp.isDelegate() : false).setTlvs(inputLsp.getTlvs()).setAdministrative((inputLsp.isAdministrative() != null) ? inputLsp.isAdministrative() : false).build());
                 } else {
@@ -336,7 +336,7 @@ final class Stateful07TopologySessionListener extends AbstractTopologySessionLis
 
     @Override
     public synchronized ListenableFuture<OperationResult> ensureLspOperational(final EnsureLspOperationalInput input) {
-        Preconditions.checkArgument(input != null && input.getName() != null & input.getNode() != null && input.getArguments() != null, "Mandatory XML tags are missing.");
+        Preconditions.checkArgument(input != null && input.getName() != null && input.getNode() != null && input.getArguments() != null, "Mandatory XML tags are missing.");
         final OperationalStatus op;
         final Arguments1 aa = input.getArguments().getAugmentation(Arguments1.class);
         if (aa != null) {
@@ -360,13 +360,13 @@ final class Stateful07TopologySessionListener extends AbstractTopologySessionLis
 
                 // check if at least one of the paths has the same status as requested
                 boolean operational = false;
-                for (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev131024.pcep.client.attributes.path.computation.client.reported.lsp.Path p : rep.get().getPath()) {
-                    Path1 p1 = p.getAugmentation(Path1.class);
+                for (final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev131024.pcep.client.attributes.path.computation.client.reported.lsp.Path p : rep.get().getPath()) {
+                    final Path1 p1 = p.getAugmentation(Path1.class);
                     if (p1 == null) {
                         LOG.warn("Node {} LSP {} does not contain data", input.getNode(), input.getName());
                         return OperationResults.UNSENT;
                     }
-                    Lsp l = p1.getLsp();
+                    final Lsp l = p1.getLsp();
                     if (l.getOperational().equals(op)) {
                         operational = true;
                     }
index d35708e909ff3406557cedc0ae73c0fd439198ac..c3d819f72bf790d5ac2e0e68b60da5cefb016fd3 100644 (file)
@@ -23,6 +23,7 @@ import io.netty.channel.EventLoop;
 import io.netty.util.concurrent.Promise;
 import java.net.InetSocketAddress;
 import java.net.SocketAddress;
+import java.util.ArrayList;
 import java.util.List;
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.TimeUnit;
@@ -91,7 +92,7 @@ public class ParserToSalTest extends AbstractDataBrokerTest {
     @Before
     public void setUp() throws Exception {
         MockitoAnnotations.initMocks(this);
-
+        this.receivedMsgs = new ArrayList<>();
         doAnswer(new Answer<Object>() {
             @Override
             public Object answer(final InvocationOnMock invocation) {
index d7099509a80b7a301f1d8ef82a8e026de757b182..9eabd2a99096dd66a9e6b3505ee260bef12c01f0 100644 (file)
@@ -12,11 +12,9 @@ import com.google.common.collect.Lists;
 import com.google.common.util.concurrent.FutureCallback;
 import com.google.common.util.concurrent.Futures;
 import com.google.common.util.concurrent.JdkFutureAdapters;
-
 import java.util.HashSet;
 import java.util.Map;
 import java.util.Set;
-
 import org.opendaylight.controller.md.sal.common.api.TransactionStatus;
 import org.opendaylight.controller.md.sal.common.api.data.DataChangeEvent;
 import org.opendaylight.controller.sal.binding.api.data.DataChangeListener;
@@ -139,7 +137,7 @@ public final class NodeChangedListener implements DataChangeListener {
 
                     if (tpt instanceof Ip) {
                         for (final IpAddress a : ((Ip) tpt).getIpAddress()) {
-                            if (addr.equals(a.getIpv6Address())) {
+                            if (addr.equals(a)) {
                                 if (sni != null) {
                                     final NodeKey k = InstanceIdentifier.keyOf(sni);
                                     boolean have = false;
@@ -265,10 +263,10 @@ public final class NodeChangedListener implements DataChangeListener {
             LOG.debug("Searching for orphan links/nodes");
             final Topology t = (Topology) trans.readOperationalData(this.target);
 
-            NodeId srcNode = l.getSource().getSourceNode();
-            NodeId dstNode = l.getDestination().getDestNode();
-            TpId srcTp = l.getSource().getSourceTp();
-            TpId dstTp = l.getDestination().getDestTp();
+            final NodeId srcNode = l.getSource().getSourceNode();
+            final NodeId dstNode = l.getDestination().getDestNode();
+            final TpId srcTp = l.getSource().getSourceTp();
+            final TpId dstTp = l.getDestination().getDestTp();
 
             boolean orphSrcNode = true, orphDstNode = true, orphDstTp = true, orphSrcTp = true;
             for (final Link lw : t.getLink()) {
index 096a2d973c70f7e676d938416e285acd59ffffe8..e556a83d6374abb9117af45e643330482e9e49e8 100644 (file)
@@ -56,8 +56,8 @@ final class InstructionImpl implements Instruction {
         return id;
     }
 
-    InstructionStatus getStatus() {
-        return status;
+    synchronized InstructionStatus getStatus() {
+        return this.status;
     }
 
     synchronized void setStatus(final InstructionStatus status, final Details details) {
index c482991cb32074deadb2f99885a6b344571ab3c2..fa69d7e5011d06fcd41daeac4aaea3d06f490460 100644 (file)
@@ -191,10 +191,10 @@ public final class ProgrammingServiceImpl implements AutoCloseable, InstructionS
             }
 
             // The instruction is in a terminal state, we need to just unlink
-            // it from its dependencies and dependants
+            // it from its dependencies and dependents
             i.clean();
 
-            insns.remove(i);
+            this.insns.remove(id);
             LOG.debug("Instruction {} cleaned successfully", id);
         }
 
index 0db409e2968cd346c96b73764f17dc550c803255..38f59021c56b9a44e6a1e646252b1368f69dd44e 100644 (file)
@@ -9,9 +9,7 @@ package org.opendaylight.protocol.util;
 
 import com.google.common.base.Preconditions;
 import com.google.common.primitives.UnsignedInteger;
-
 import io.netty.buffer.ByteBuf;
-
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.IOException;
@@ -20,7 +18,6 @@ import java.nio.charset.CharacterCodingException;
 import java.nio.charset.Charset;
 import java.util.Arrays;
 import java.util.BitSet;
-
 import org.apache.commons.codec.binary.Hex;
 
 /**
@@ -38,10 +35,10 @@ public final class ByteArray {
      * @param length length of the returned byte array
      * @return byte array
      */
-    public static byte[] readBytes(final ByteBuf buffer, int length) {
-        Preconditions.checkState(buffer != null && buffer.readableBytes() >= length,
-                "Buffer cannot be read for %s bytes. Contains only %s bytes.", length, buffer.readableBytes());
-        byte[] result = new byte[length];
+    public static byte[] readBytes(final ByteBuf buffer, final int length) {
+        Preconditions.checkArgument(buffer != null && buffer.readableBytes() >= length,
+                "Buffer cannot be read for %s bytes.", length);
+        final byte[] result = new byte[length];
         buffer.readBytes(result);
         return result;
     }
@@ -65,10 +62,10 @@ public final class ByteArray {
      * @param length length of the returned byte array
      * @return byte array
      */
-    public static byte[] getBytes(final ByteBuf buffer, int length) {
-        Preconditions.checkState(buffer != null && buffer.readableBytes() >= length,
-                "Buffer cannot be read for %s bytes. Contains only %s bytes.", length, buffer.readableBytes());
-        byte[] result = new byte[length];
+    public static byte[] getBytes(final ByteBuf buffer, final int length) {
+        Preconditions.checkArgument(buffer != null && buffer.readableBytes() >= length,
+                "Buffer cannot be read for %s bytes.", length);
+        final byte[] result = new byte[length];
         buffer.getBytes(buffer.readerIndex(), result);
         return result;
     }
index 3d3d3ea9216e3e6b8636c9feb58472ada17c56df..fe22f9a36e4852d4492a7bea8edad20b8db0fdd1 100644 (file)
@@ -10,14 +10,12 @@ package org.opendaylight.protocol.util;
 import com.google.common.base.Preconditions;
 import com.google.common.collect.Lists;
 import com.google.common.io.CharStreams;
-
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.InputStreamReader;
 import java.util.List;
-
 import org.apache.commons.codec.DecoderException;
 import org.apache.commons.codec.binary.Hex;
 import org.slf4j.Logger;
@@ -62,21 +60,20 @@ public final class PCEPHexDumpParser {
             // next chars are final length, ending with '.'
             final int lengthIdx = idx + LENGTH.length();
             final int messageIdx = content.indexOf('.', lengthIdx);
-
             final int length = Integer.valueOf(content.substring(lengthIdx, messageIdx));
-            final int messageEndIdx = idx + length * 2;
+            final int messageEndIdx = messageIdx + (length * 2) + 1;    // dot
 
             // Assert that message is longer than minimum 4(header.length == 4)
             // If length in PCEP message would be 0, loop would never end
             Preconditions.checkArgument(length >= MINIMAL_LENGTH, "Invalid message at index " + idx + ", length atribute is lower than "
                     + MINIMAL_LENGTH);
 
-            final String hexMessage = content.substring(idx, messageEndIdx);
+            final String hexMessage = content.substring(messageIdx + 1, messageEndIdx); // dot
             byte[] message = null;
             try {
                 message = Hex.decodeHex(hexMessage.toCharArray());
             } catch (final DecoderException e) {
-                new IllegalArgumentException("Failed to decode message", e);
+                throw new IllegalArgumentException("Failed to decode message", e);
             }
             messages.add(message);
             idx = messageEndIdx;