BUG-731 : removed more warnings 62/12462/2
authorDana Kutenicsova <dkutenic@cisco.com>
Mon, 3 Nov 2014 16:10:58 +0000 (17:10 +0100)
committerDana Kutenicsova <dkutenic@cisco.com>
Tue, 4 Nov 2014 14:23:18 +0000 (15:23 +0100)
Change-Id: I82b253f3e11e8155ea7dae61ecd47906565cfcb7
Signed-off-by: Dana Kutenicsova <dkutenic@cisco.com>
17 files changed:
bgp/parser-api/src/main/java/org/opendaylight/protocol/bgp/parser/BGPError.java
bgp/parser-impl/src/main/java/org/opendaylight/protocol/bgp/parser/impl/message/update/ExtendedCommunitiesAttributeParser.java
bgp/parser-spi/src/main/java/org/opendaylight/protocol/bgp/parser/spi/pojo/SimpleAddressFamilyRegistry.java
bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/AdjRIBOutEntry.java
bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/RIBImpl.java
bgp/rib-impl/src/test/java/org/opendaylight/protocol/bgp/rib/impl/ApplicationPeerTest.java
bgp/rib-spi/src/main/java/org/opendaylight/protocol/bgp/rib/spi/BGPObjectComparator.java
bgp/util/src/main/java/org/opendaylight/protocol/bgp/util/HexDumpBGPFileParser.java
data-change-counter/src/main/java/org/opendaylight/controller/config/yang/bgpcep/data/change/counter/DataChangeCounterImplModule.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/Activator.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/message/PCEPErrorMessageParser.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/PCEPErrorObjectParser.java
pcep/spi/src/main/java/org/opendaylight/protocol/pcep/spi/PCEPErrors.java
pcep/testtool/src/main/java/org/opendaylight/protocol/pcep/testtool/Main.java
pcep/topology-provider/src/main/java/org/opendaylight/bgpcep/pcep/topology/provider/AbstractTopologySessionListener.java
util/src/main/java/org/opendaylight/protocol/util/PCEPHexDumpParser.java

index ed7de231cc7163920d48f434eb57122b1b7d70fc..85ca0c500ea8c95dd71182283d5d3f2d6ced5a97 100644 (file)
@@ -173,7 +173,7 @@ public enum BGPError {
     /**
      * Caret for combination of Error-type and Error-value
      */
-    private static class BGPErrorIdentifier {
+    static class BGPErrorIdentifier {
         private final short code;
         private final short subcode;
 
index 38b5f60aee910700c38e9087e4a52a3ad8a7c51a..42fb8ad4494f79169be5cf8ecfb24a069fdcd855 100644 (file)
@@ -134,11 +134,9 @@ public final class ExtendedCommunitiesAttributeParser implements AttributeParser
             as = new ShortAsNumber((long) buffer.readUnsignedShort());
             value = ByteArray.readBytes(buffer, AS_LOCAL_ADMIN_LENGTH);
             if (comm.getCommSubType() == ROUTE_TARGET_SUBTYPE) {
-                c = new RouteTargetExtendedCommunityCaseBuilder().setRouteTargetExtendedCommunity(
-                    new RouteTargetExtendedCommunityBuilder().setGlobalAdministrator(as).setLocalAdministrator(value).build()).build();
+                c = new RouteTargetExtendedCommunityCaseBuilder().setRouteTargetExtendedCommunity(new RouteTargetExtendedCommunityBuilder().setGlobalAdministrator(as).setLocalAdministrator(value).build()).build();
             } else if (comm.getCommSubType() == ROUTE_ORIGIN_SUBTYPE) {
-                c = new RouteOriginExtendedCommunityCaseBuilder().setRouteOriginExtendedCommunity(
-                    new RouteOriginExtendedCommunityBuilder().setGlobalAdministrator(as).setLocalAdministrator(value).build()).build();
+                c = new RouteOriginExtendedCommunityCaseBuilder().setRouteOriginExtendedCommunity(new RouteOriginExtendedCommunityBuilder().setGlobalAdministrator(as).setLocalAdministrator(value).build()).build();
             } else {
                 throw new BGPDocumentedException("Could not parse Extended Community subtype: " + comm.getCommSubType(), BGPError.OPT_ATTR_ERROR);
             }
@@ -166,12 +164,10 @@ public final class ExtendedCommunitiesAttributeParser implements AttributeParser
                         ByteArray.readBytes(buffer, INET_LOCAL_ADMIN_LENGTH)).build()).build();
             break;
         case OPAQUE_TYPE_TRANS:
-            c = new OpaqueExtendedCommunityCaseBuilder().setOpaqueExtendedCommunity(
-                new OpaqueExtendedCommunityBuilder().setTransitive(false).setValue(ByteArray.readAllBytes(buffer)).build()).build();
+            c = new OpaqueExtendedCommunityCaseBuilder().setOpaqueExtendedCommunity(new OpaqueExtendedCommunityBuilder().setTransitive(false).setValue(ByteArray.readAllBytes(buffer)).build()).build();
             break;
         case OPAQUE_TYPE_NON_TRANS:
-            c = new OpaqueExtendedCommunityCaseBuilder().setOpaqueExtendedCommunity(
-                new OpaqueExtendedCommunityBuilder().setTransitive(true).setValue(ByteArray.readAllBytes(buffer)).build()).build();
+            c = new OpaqueExtendedCommunityCaseBuilder().setOpaqueExtendedCommunity(new OpaqueExtendedCommunityBuilder().setTransitive(true).setValue(ByteArray.readAllBytes(buffer)).build()).build();
             break;
         default:
             throw new BGPDocumentedException("Could not parse Extended Community type: " + comm.getCommType(), BGPError.OPT_ATTR_ERROR);
index 5ececa2826bc5a4fff6bff1544fff8b2e81d4537..3d6be1218c5d06918d515188e572ef590c995b51 100644 (file)
@@ -8,7 +8,6 @@
 package org.opendaylight.protocol.bgp.parser.spi.pojo;
 
 import com.google.common.base.Preconditions;
-
 import org.opendaylight.protocol.bgp.parser.spi.AddressFamilyRegistry;
 import org.opendaylight.protocol.util.Values;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.AddressFamily;
index 2a5544d51e0b4cf5af0977a8b0051ad9ad367d18..4e02d4725d4e1136be2f6cd3a3e2cbc254332a08 100644 (file)
@@ -66,10 +66,10 @@ final class AdjRIBOutEntry<K, V extends Route> {
     }
 
     RouteEncoder getRibOut() {
-        return ribOut;
+        return this.ribOut;
     }
 
     static boolean isNone(final Object o) {
-        return o == NLRIENTRY_NONE_VALUE;
+        return NLRIENTRY_NONE_VALUE.equals(o);
     }
 }
\ No newline at end of file
index 3a9a353402a549098069161cc01dc194afc2b70e..43087a58d6e7e94bcd0f56ebdd5b8ead029b3cb8 100644 (file)
@@ -96,7 +96,8 @@ public final class RIBImpl extends DefaultRibReference implements AutoCloseable,
     private final RIBTables tables;
     private final BlockingQueue<Peer> peers;
     private final DataBroker dataBroker;
-    private final Thread scheduler = new Thread(new Runnable() {
+
+    private final Runnable scheduler = new Runnable() {
         @Override
         public void run() {
             try {
@@ -121,7 +122,7 @@ public final class RIBImpl extends DefaultRibReference implements AutoCloseable,
                 LOG.info("Scheduler thread was interrupted.", e);
             }
         }
-    });
+    };
 
     public RIBImpl(final RibId ribId, final AsNumber localAs, final Ipv4Address localBgpId, final RIBExtensionConsumerContext extensions,
         final BGPDispatcher dispatcher, final ReconnectStrategyFactory tcpStrategyFactory,
@@ -369,7 +370,7 @@ public final class RIBImpl extends DefaultRibReference implements AutoCloseable,
         LOG.debug("Registering this peer {} to RIB-Out {}", peer, this.ribOuts);
         try {
             this.peers.put(peer);
-            this.scheduler.run();
+            new Thread(this.scheduler).start();
         } catch (final InterruptedException e) {
             //
         }
@@ -405,7 +406,7 @@ public final class RIBImpl extends DefaultRibReference implements AutoCloseable,
                     }
                 }
             }
-        } catch (ReadFailedException e) {
+        } catch (final ReadFailedException e) {
             //no-op
         }
         return 0;
index e50b53421911640636dbef8309a7deba226a12e8..28a735d7d68ce3c981a2dc7452404bf911ed3c21 100644 (file)
@@ -199,6 +199,7 @@ public class ApplicationPeerTest {
         Mockito.doNothing().when(this.future).addListener(Mockito.any(Runnable.class), Mockito.any(Executor.class));
         Mockito.doReturn(this.transWrite).when(this.chain).newWriteOnlyTransaction();
         Mockito.doReturn(this.eventLoop).when(this.channel).eventLoop();
+        Mockito.doReturn("channel").when(this.channel).toString();
         Mockito.doAnswer(new Answer<Object>() {
 
             @Override
@@ -297,7 +298,7 @@ public class ApplicationPeerTest {
         //create new peer so that it gets advertized routes from RIB
         try (final BGPPeer testingPeer = new BGPPeer("testingPeer", this.r)) {
             testingPeer.onSessionUp(this.session);
-            assertEquals(4, this.routes.size());
+            assertEquals(2, this.routes.size());
             assertEquals(1, testingPeer.getBgpPeerState().getSessionEstablishedCount().intValue());
             assertEquals(1, testingPeer.getBgpPeerState().getRouteTable().size());
             assertNotNull(testingPeer.getBgpSessionState());
index 08c1e820309486494e7622633bf88e07e71c614a..c76102a56bda1ea65be494309265ff83e95749c5 100644 (file)
@@ -10,6 +10,7 @@ package org.opendaylight.protocol.bgp.rib.spi;
 import com.google.common.annotations.VisibleForTesting;
 import com.google.common.base.Preconditions;
 import com.google.common.net.InetAddresses;
+import java.io.Serializable;
 import java.util.Arrays;
 import java.util.Comparator;
 import java.util.List;
@@ -28,7 +29,10 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.type
  *
  * @param <T> Actual object state reference
  */
-public final class BGPObjectComparator implements Comparator<RIBEntryData<?, ?, ?>> {
+public final class BGPObjectComparator implements Comparator<RIBEntryData<?, ?, ?>>, Serializable {
+
+    private static final long serialVersionUID = 3299599519482155374L;
+
     private final AsNumber ourAS;
 
     public BGPObjectComparator(final AsNumber ourAs) {
index 7e6bbc01caf134535ed646b5a6d0d164e671a9a7..412e30e64652729dd5d572b086a8ec9b8bfee2f7 100644 (file)
@@ -47,7 +47,7 @@ public final class HexDumpBGPFileParser {
 
     public static List<byte[]> parseMessages(final InputStream is) throws IOException {
         Preconditions.checkNotNull(is);
-        try (InputStreamReader isr = new InputStreamReader(is)) {
+        try (InputStreamReader isr = new InputStreamReader(is, "UTF-8")) {
             return parseMessages(CharStreams.toString(isr));
         } finally {
             is.close();
index 56c4ce83266653f50825ac3c6b8f075080db1aa0..64ffe5d0c6c181e6ddbe9d082d6e461a8dd29914 100644 (file)
@@ -49,7 +49,7 @@ public class DataChangeCounterImplModule extends org.opendaylight.controller.con
         return new DataChangeCounterCloseable(counter, registration);
     }
 
-    private final class DataChangeCounterCloseable implements AutoCloseable {
+    private static final class DataChangeCounterCloseable implements AutoCloseable {
 
         private final TopologyDataChangeCounter inner;
         private final ListenerRegistration<DataChangeListener> registration;
index 45223efbe2f1fee51edbebbfafc20bca7c8782fa..fe138011b86d7f941aa3f434485fc03faff0702d 100644 (file)
@@ -230,6 +230,11 @@ public final class Activator extends AbstractPCEPExtensionProviderActivator {
         regs.add(context.registerObjectParser(PCEPCloseObjectParser.CLASS, PCEPCloseObjectParser.TYPE, closeParser));
         regs.add(context.registerObjectSerializer(CClose.class, closeParser));
 
+        registerExtensionsObjectParsers(regs, context, tlvReg, viTlvReg, eroSubReg);
+    }
+
+    private void registerExtensionsObjectParsers(final List<AutoCloseable> regs, final PCEPExtensionProviderContext context,
+        final TlvRegistry tlvReg, final VendorInformationTlvRegistry viTlvReg, final EROSubobjectRegistry eroSubReg) {
         final PCEPPathKeyObjectParser pathKeyParser = new PCEPPathKeyObjectParser(eroSubReg);
         regs.add(context.registerObjectParser(PCEPPathKeyObjectParser.CLASS, PCEPPathKeyObjectParser.TYPE, pathKeyParser));
         regs.add(context.registerObjectSerializer(
index bb465e27d370121842160a52d28f2b1cf4bda1af..630d6a3a1dee791accb4deecce5b074d6062813f 100644 (file)
@@ -79,7 +79,6 @@ public class PCEPErrorMessageParser extends AbstractMessageParser {
         if (objects == null) {
             throw new IllegalArgumentException("Passed list can't be null.");
         }
-
         if (objects.isEmpty()) {
             throw new PCEPDeserializerException("Error message is empty.");
         }
@@ -87,15 +86,13 @@ public class PCEPErrorMessageParser extends AbstractMessageParser {
         final List<Errors> errorObjects = new ArrayList<>();
         final PcerrMessageBuilder b = new PcerrMessageBuilder();
 
-        Object obj;
+        Object obj = objects.get(0);
         State state = State.Init;
-        obj = objects.get(0);
 
         if (obj instanceof ErrorObject) {
             final ErrorObject o = (ErrorObject) obj;
             errorObjects.add(new ErrorsBuilder().setErrorObject(o).build());
             state = State.ErrorIn;
-            objects.remove(0);
         } else if (obj instanceof Rp) {
             final Rp o = (Rp) obj;
             if (o.isProcessingRule()) {
@@ -104,15 +101,16 @@ public class PCEPErrorMessageParser extends AbstractMessageParser {
             }
             requestParameters.add(new RpsBuilder().setRp(o).build());
             state = State.RpIn;
-            objects.remove(0);
         }
+        if (state.equals(State.Init)) {
+            throw new PCEPDeserializerException("At least one PCEPErrorObject is mandatory.");
+        }
+        objects.remove(0);
         while (!objects.isEmpty()) {
             obj = objects.get(0);
-
             if (obj instanceof UnknownObject) {
                 return new PcerrBuilder().setPcerrMessage(b.setErrors(((UnknownObject) obj).getErrors()).build()).build();
             }
-
             switch (state) {
             case ErrorIn:
                 state = State.Open;
@@ -156,18 +154,15 @@ public class PCEPErrorMessageParser extends AbstractMessageParser {
                 objects.remove(0);
             }
         }
-
         if (errorObjects.isEmpty()) {
             throw new PCEPDeserializerException("At least one PCEPErrorObject is mandatory.");
         }
-
         if (!objects.isEmpty()) {
             throw new PCEPDeserializerException("Unprocessed Objects: " + objects);
         }
         if (!requestParameters.isEmpty()) {
             b.setErrorType(new RequestCaseBuilder().setRequest(new RequestBuilder().setRps(requestParameters).build()).build());
         }
-
         return new PcerrBuilder().setPcerrMessage(b.setErrors(errorObjects).build()).build();
     }
 
index 256a015f314c8103a567d7afc2c83a4da8b1b29f..a0d46ec99e319b08fd8fd96c74cfc55be816dc8a 100644 (file)
@@ -93,7 +93,7 @@ public class PCEPReplyMessageParser extends AbstractMessageParser {
                 }
             } else {
                 final SuccessCase s = (SuccessCase) reply.getResult();
-                if (s != null) {
+                if (s != null && s.getSuccess() != null) {
                     for (final Paths p : s.getSuccess().getPaths()) {
                         serializeObject(p.getEro(), buffer);
                         serializeObject(p.getLspa(), buffer);
@@ -106,8 +106,8 @@ public class PCEPReplyMessageParser extends AbstractMessageParser {
                         }
                         serializeObject(p.getIro(), buffer);
                     }
+                    serializeVendorInformationObjects(s.getSuccess().getVendorInformationObject(), buffer);
                 }
-                serializeVendorInformationObjects(s.getSuccess().getVendorInformationObject(), buffer);
             }
         }
     }
index e3a0c1de45b245257f131a3a6c98976a38e1db52..62497fc151dfafae234e35dacc0644281498aa2d 100644 (file)
@@ -17,6 +17,7 @@ import java.util.List;
 import org.opendaylight.protocol.pcep.spi.AbstractObjectWithTlvsParser;
 import org.opendaylight.protocol.pcep.spi.ObjectUtil;
 import org.opendaylight.protocol.pcep.spi.PCEPDeserializerException;
+import org.opendaylight.protocol.pcep.spi.PCEPErrors;
 import org.opendaylight.protocol.pcep.spi.TlvRegistry;
 import org.opendaylight.protocol.pcep.spi.VendorInformationTlvRegistry;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Object;
@@ -61,7 +62,7 @@ public class PCEPErrorObjectParser extends AbstractObjectWithTlvsParser<ErrorObj
 
     @Override
     public void addTlv(final ErrorObjectBuilder builder, final Tlv tlv) {
-        if (tlv instanceof ReqMissing && builder.getType() == 7) {
+        if (tlv instanceof ReqMissing && builder.getType() == PCEPErrors.SYNC_PATH_COMP_REQ_MISSING.getErrorType()) {
             builder.setTlvs(new TlvsBuilder().setReqMissing((ReqMissing) tlv).build());
         }
     }
index 2f946f11940cb91eefabaeaedf26c33f76d874c2..d61808b4b6b35c7e9d9ccb125458f0fa511b7210 100644 (file)
@@ -305,7 +305,7 @@ public enum PCEPErrors {
     /**
      * Caret for combination of Error-type and Error-value
      */
-    private static class PCEPErrorIdentifier {
+    static class PCEPErrorIdentifier {
         private final short type;
         private final short value;
 
index e997fd25f5f2a4c88c2ee133f6c3297ead10ccee..5b1f0625b7cccb189ae81ffe50e4a9a5b30d02da 100644 (file)
@@ -68,6 +68,8 @@ public final class Main {
 
     private static final int KA_TO_DEADTIMER_RATIO = 4;
 
+    private static final int KA_DEFAULT = 30;
+
     public static void main(final String[] args) throws UnknownHostException, InterruptedException, ExecutionException {
         if (args.length == 0 || (args.length == 1 && args[0].equalsIgnoreCase("--help"))) {
             LOG.info(Main.USAGE);
@@ -75,7 +77,7 @@ public final class Main {
         }
 
         InetSocketAddress address = null;
-        int keepAliveValue = 30;
+        int keepAliveValue = KA_DEFAULT;
         int deadTimerValue = 0;
         boolean stateful = false;
         boolean active = false;
index 4f5f320eaabe4ca188312d7cc42a1d552a8f489f..36d86dcd4078083f79df2b1ab08f718bc3ed8f80 100644 (file)
@@ -481,7 +481,7 @@ public abstract class AbstractTopologySessionListener<S, L> implements PCEPSessi
     }
 
     @Override
-    public SessionState getSessionState() {
+    public synchronized SessionState getSessionState() {
         return this.listenerState.getSessionState(this.session);
     }
 
index 566e7a2589bb4a271052f4ce1ae77c12eba991df..803104476faf304e1190200ecca559ca1df88c98 100644 (file)
@@ -44,7 +44,7 @@ public final class PCEPHexDumpParser {
 
     public static List<byte[]> parseMessages(final InputStream is) throws IOException {
         Preconditions.checkNotNull(is);
-        try (InputStreamReader isr = new InputStreamReader(is)) {
+        try (InputStreamReader isr = new InputStreamReader(is, "UTF-8")) {
             return parseMessages(CharStreams.toString(isr));
         }
     }