Enforce findbug and checkstyle 94/66794/1
authorClaudio D. Gasparini <claudio.gasparini@pantheon.tech>
Tue, 26 Dec 2017 20:38:59 +0000 (21:38 +0100)
committerClaudio D. Gasparini <claudio.gasparini@pantheon.tech>
Thu, 28 Dec 2017 22:01:41 +0000 (23:01 +0100)
under modules

- openconfig-api
- parser-api
- ri-api
- testool
- util

Change-Id: I01838e001689835f1d4f4b3dab5c1e3fe311fc72
Signed-off-by: Claudio D. Gasparini <claudio.gasparini@pantheon.tech>
28 files changed:
bgp/openconfig-api/pom.xml
bgp/parser-api/pom.xml
bgp/parser-api/src/main/java/org/opendaylight/protocol/bgp/parser/BGPDocumentedException.java
bgp/parser-api/src/main/java/org/opendaylight/protocol/bgp/parser/BGPError.java
bgp/parser-api/src/main/java/org/opendaylight/protocol/bgp/parser/BGPErrorIdentifier.java [deleted file]
bgp/parser-api/src/main/java/org/opendaylight/protocol/bgp/parser/BGPParsingException.java
bgp/parser-api/src/main/java/org/opendaylight/protocol/bgp/parser/BgpExtendedMessageUtil.java
bgp/parser-api/src/main/java/org/opendaylight/protocol/bgp/parser/BgpTableTypeImpl.java
bgp/parser-api/src/test/java/org/opendaylight/protocol/bgp/parser/APITest.java
bgp/parser-api/src/test/java/org/opendaylight/protocol/bgp/parser/TableTypeTest.java
bgp/rib-api/pom.xml
bgp/rib-api/src/main/java/org/opendaylight/protocol/bgp/rib/DefaultRibReference.java
bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/LocRibWriter.java
bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/RIBImpl.java
bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/spi/BGPDispatcher.java
bgp/testtool/pom.xml
bgp/testtool/src/main/java/org/opendaylight/protocol/bgp/testtool/Arguments.java
bgp/testtool/src/main/java/org/opendaylight/protocol/bgp/testtool/BGPPeerBuilder.java
bgp/testtool/src/main/java/org/opendaylight/protocol/bgp/testtool/BGPTestTool.java
bgp/testtool/src/main/java/org/opendaylight/protocol/bgp/testtool/CommunitiesBuilder.java
bgp/testtool/src/main/java/org/opendaylight/protocol/bgp/testtool/Main.java
bgp/testtool/src/main/java/org/opendaylight/protocol/bgp/testtool/PrefixesBuilder.java
bgp/testtool/src/main/java/org/opendaylight/protocol/bgp/testtool/TestingListener.java
bgp/util/pom.xml
bgp/util/src/main/java/org/opendaylight/protocol/bgp/util/BinaryBGPDumpFileParser.java
bgp/util/src/main/java/org/opendaylight/protocol/bgp/util/HexDumpBGPFileParser.java
bgp/util/src/test/java/org/opendaylight/protocol/bgp/util/BGPBinaryFileParserTest.java
bgp/util/src/test/java/org/opendaylight/protocol/bgp/util/BGPHexFileParserTest.java

index 4c32363fecc59b4ca286c7f4e51cb55935cca72c..d8282f11ab567382e6474ebcc3c49ccfd1d82a37 100644 (file)
         </dependency>
     </dependencies>
 
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-checkstyle-plugin</artifactId>
+                <configuration>
+                    <propertyExpansion>checkstyle.violationSeverity=error</propertyExpansion>
+                </configuration>
+            </plugin>
+            <plugin>
+                <groupId>org.codehaus.mojo</groupId>
+                <artifactId>findbugs-maven-plugin</artifactId>
+                <configuration>
+                    <failOnError>true</failOnError>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+
     <scm>
         <connection>scm:git:ssh://git.opendaylight.org:29418/bgpcep.git</connection>
         <developerConnection>scm:git:ssh://git.opendaylight.org:29418/bgpcep.git</developerConnection>
index ab23904defc392deff55f315fd3067f968157fc1..933b2bf9ee12df891e4f6b8457e2c08270a690d3 100644 (file)
         </dependency>
     </dependencies>
 
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-checkstyle-plugin</artifactId>
+                <configuration>
+                    <propertyExpansion>checkstyle.violationSeverity=error</propertyExpansion>
+                </configuration>
+            </plugin>
+            <plugin>
+                <groupId>org.codehaus.mojo</groupId>
+                <artifactId>findbugs-maven-plugin</artifactId>
+                <configuration>
+                    <failOnError>true</failOnError>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+
     <scm>
         <connection>scm:git:ssh://git.opendaylight.org:29418/bgpcep.git</connection>
         <developerConnection>scm:git:ssh://git.opendaylight.org:29418/bgpcep.git</developerConnection>
index a97c5d7679dc1ee29d27aa7bf2f8174feb3d7916..d262d3fa7e2f111890760448a63f93ad9e97a17c 100644 (file)
@@ -15,8 +15,8 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 /**
- * There are several errors documented in RFC4271 or in draft, that have specific meaning for the BGP. This exception is
- * used, when any of those errors occurs.
+ * There are several errors documented in RFC4271 or in draft, that have specific meaning for the BGP.
+ * This exception is used, when any of those errors occurs.
  */
 public final class BGPDocumentedException extends Exception {
 
@@ -77,7 +77,8 @@ public final class BGPDocumentedException extends Exception {
      * @param data data associated with the error
      * @param cause cause for the error
      */
-    public BGPDocumentedException(final String message, final BGPError error, final byte[] data, final Exception cause) {
+    public BGPDocumentedException(final String message, final BGPError error, final byte[] data,
+            final Exception cause) {
         super(message, cause);
         this.error = error;
         this.data = data == null ? null : Arrays.copyOf(data, data.length);
index 479e93dfc5d592521286b20afb058334003600ac..1e900dfdae2ad8f7b0d9b2ca58fe57c24cf6aec3 100644 (file)
@@ -9,12 +9,13 @@ package org.opendaylight.protocol.bgp.parser;
 
 import com.google.common.base.Preconditions;
 import com.google.common.collect.Maps;
+import java.io.Serializable;
 import java.util.Map;
 
 
 /**
- * Possible errors from implemented RFCs and drafts. Each error consists of error code and error subcode (code/subcode
- * in comments).
+ * Possible errors from implemented RFCs and drafts. Each error consists of error code and error subcode
+ * (code/subcode in comments).
  *
  * @see <a href="http://tools.ietf.org/html/rfc4271#section-4.5">BGP Notification Message</a>
  */
@@ -140,7 +141,7 @@ public enum BGPError {
      */
     OUT_OF_RESOURCES((short) 6, (short) 8),
     /**
-     * Unsupported Capability 2/7
+     * Unsupported Capability. 2/7
      */
     UNSUPPORTED_CAPABILITY((short) 2, (short) 7);
 
@@ -161,21 +162,62 @@ public enum BGPError {
         this.errorId = new BGPErrorIdentifier(code, subcode);
     }
 
+    public static BGPError forValue(final int code, final int subcode) {
+        final BGPError e = VALUE_MAP.get(new BGPErrorIdentifier((short) code, (short) subcode));
+        Preconditions.checkArgument(e != null, "BGP Error code %s and subcode %s not recognized.",
+                code, subcode);
+        return e;
+    }
+
     public short getCode() {
-        return this.errorId.getCode();
+        return this.errorId.code;
     }
 
     public short getSubcode() {
-        return this.errorId.getSubCode();
+        return this.errorId.subcode;
     }
 
     private BGPErrorIdentifier getErrorIdentifier() {
         return this.errorId;
     }
 
-    public static BGPError forValue(final int code, final int subcode) {
-        final BGPError e = VALUE_MAP.get(new BGPErrorIdentifier((short) code, (short) subcode));
-        Preconditions.checkArgument(e != null, "BGP Error code %s and subcode %s not recognized.", code, subcode);
-        return e;
+    /**
+     * Caret for combination of Error-type and Error-value.
+     */
+    private static class BGPErrorIdentifier implements Serializable {
+        private static final long serialVersionUID = 5722575354944165734L;
+        final short code;
+        final short subcode;
+
+        BGPErrorIdentifier(final short code, final short subcode) {
+            this.code = code;
+            this.subcode = subcode;
+        }
+
+        @Override
+        public int hashCode() {
+            final int prime = 31;
+            int result = 1;
+            result = prime * result + this.code;
+            result = prime * result + this.subcode;
+            return result;
+        }
+
+        @Override
+        public boolean equals(final java.lang.Object obj) {
+            if (this == obj) {
+                return true;
+            }
+            if (obj == null || this.getClass() != obj.getClass()) {
+                return false;
+            }
+            final BGPErrorIdentifier other = (BGPErrorIdentifier) obj;
+            return this.code == other.code && this.subcode == other.subcode;
+        }
+
+        @Override
+        public String toString() {
+            return "type " + this.code + " value " + this.subcode;
+        }
     }
 }
diff --git a/bgp/parser-api/src/main/java/org/opendaylight/protocol/bgp/parser/BGPErrorIdentifier.java b/bgp/parser-api/src/main/java/org/opendaylight/protocol/bgp/parser/BGPErrorIdentifier.java
deleted file mode 100644 (file)
index 6ff2173..0000000
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.protocol.bgp.parser;
-
-import java.io.Serializable;
-
-/**
- * Caret for combination of Error-type and Error-value
- */
-final class BGPErrorIdentifier implements Serializable {
-    private static final long serialVersionUID = 5722575354944165734L;
-    private final short code;
-    private final short subcode;
-
-    BGPErrorIdentifier(final short code, final short subcode) {
-        this.code = code;
-        this.subcode = subcode;
-    }
-
-    public short getCode() {
-        return this.code;
-    }
-
-    public short getSubCode() {
-        return this.subcode;
-    }
-
-    @Override
-    public int hashCode() {
-        final int prime = 31;
-        int result = 1;
-        result = prime * result + this.code;
-        result = prime * result + this.subcode;
-        return result;
-    }
-
-    @Override
-    public boolean equals(final java.lang.Object obj) {
-        if (this == obj) {
-            return true;
-        }
-        if (obj == null || this.getClass() != obj.getClass()) {
-            return false;
-        }
-        final BGPErrorIdentifier other = (BGPErrorIdentifier) obj;
-        if (this.code != other.code || this.subcode != other.subcode) {
-            return false;
-        }
-        return true;
-    }
-
-    @Override
-    public String toString() {
-        return "type " + this.code + " value " + this.subcode;
-    }
-}
index 721e65a46d3c51eae33916beb08c9a1be9778a4f..6656e370f3454b7de9fe7033405ca802dccea5f2 100644 (file)
@@ -8,9 +8,7 @@
 package org.opendaylight.protocol.bgp.parser;
 
 /**
- *
  * Used when something occurs during the parsing to get Update Message.
- *
  */
 public class BGPParsingException extends Exception {
     private static final long serialVersionUID = 1L;
@@ -28,7 +26,7 @@ public class BGPParsingException extends Exception {
      * Creates new BGPParsingException with specific message and cause.
      *
      * @param message exception message
-     * @param cause primary exception
+     * @param cause   primary exception
      */
     public BGPParsingException(final String message, final Exception cause) {
         super(message, cause);
index ef230bebba900cc5c8ab7b41c162f32eca4139b0..14004bb2ab39ec905a54eadaf0744b3c7e725f77 100644 (file)
@@ -18,7 +18,8 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.mess
 public final class BgpExtendedMessageUtil {
 
     public static final CParameters EXTENDED_MESSAGE_CAPABILITY =
-            new CParametersBuilder().setBgpExtendedMessageCapability(new BgpExtendedMessageCapabilityBuilder().build()).build();
+            new CParametersBuilder().setBgpExtendedMessageCapability(new BgpExtendedMessageCapabilityBuilder()
+                    .build()).build();
 
     private BgpExtendedMessageUtil() {
         throw new UnsupportedOperationException();
index 3a6c07010b720ee7c94cda109dd6dd14fea31918..5e3402f5596f5ba9aee1080037902f1cd49990f7 100644 (file)
@@ -28,7 +28,8 @@ public final class BgpTableTypeImpl implements BgpTableType {
      * @param afi Address Family Identifier
      * @param safi Subsequent Address Family Identifier
      */
-    public BgpTableTypeImpl(final Class<? extends AddressFamily> afi, final Class<? extends SubsequentAddressFamily> safi) {
+    public BgpTableTypeImpl(final Class<? extends AddressFamily> afi,
+            final Class<? extends SubsequentAddressFamily> safi) {
         this.afi = requireNonNull(afi, "Address family may not be null");
         this.safi = requireNonNull(safi, "Subsequent address family may not be null");
     }
index 7fe79ceb12a1ca4feb177710088cf527ac890a60..40bb82db5bc2205a554737379fde9bd5e9ccbf14 100644 (file)
@@ -9,8 +9,6 @@ package org.opendaylight.protocol.bgp.parser;
 
 import static org.junit.Assert.assertEquals;
 
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
 import java.util.ArrayList;
 import java.util.List;
 import org.junit.Test;
@@ -59,12 +57,12 @@ public class APITest {
     public void testAsNumberUtil() {
         final List<BgpParameters> params = new ArrayList<>();
         final List<OptionalCapabilities> capas = new ArrayList<>();
-        capas.add(new OptionalCapabilitiesBuilder().setCParameters( new CParametersBuilder().addAugmentation(
-            CParameters1.class, new CParameters1Builder().setMultiprotocolCapability( new MultiprotocolCapabilityBuilder()
-                .build()).build()).build()).build());
+        capas.add(new OptionalCapabilitiesBuilder().setCParameters(new CParametersBuilder().addAugmentation(
+                CParameters1.class, new CParameters1Builder().setMultiprotocolCapability(
+                        new MultiprotocolCapabilityBuilder().build()).build()).build()).build());
         capas.add(new OptionalCapabilitiesBuilder().setCParameters(
-            new CParametersBuilder().setAs4BytesCapability( new As4BytesCapabilityBuilder().setAsNumber(
-                new AsNumber(35L)).build()).build()).build());
+                new CParametersBuilder().setAs4BytesCapability(new As4BytesCapabilityBuilder().setAsNumber(
+                        new AsNumber(35L)).build()).build()).build());
         params.add(new BgpParametersBuilder().setOptionalCapabilities(capas).build());
         final Open open1 = new OpenBuilder().setBgpParameters(params).build();
         assertEquals(35L, AsNumberUtil.advertizedAsNumber(open1).getValue().longValue());
@@ -77,24 +75,14 @@ public class APITest {
     public void testBgpExtendedMessageUtil() {
         final List<BgpParameters> params = new ArrayList<>();
         final List<OptionalCapabilities> capas = new ArrayList<>();
-        capas.add(new OptionalCapabilitiesBuilder().setCParameters( new CParametersBuilder().addAugmentation(
-            CParameters1.class, new CParameters1Builder().setMultiprotocolCapability( new MultiprotocolCapabilityBuilder()
-                .build()).build()).build()).build());
+        capas.add(new OptionalCapabilitiesBuilder().setCParameters(new CParametersBuilder().addAugmentation(
+                CParameters1.class, new CParameters1Builder()
+                        .setMultiprotocolCapability(new MultiprotocolCapabilityBuilder()
+                                .build()).build()).build()).build());
         capas.add(new OptionalCapabilitiesBuilder().setCParameters(
                 BgpExtendedMessageUtil.EXTENDED_MESSAGE_CAPABILITY).build());
         params.add(new BgpParametersBuilder().setOptionalCapabilities(capas).build());
         final Open open1 = new OpenBuilder().setBgpParameters(params).build();
         assertEquals(true, BgpExtendedMessageUtil.advertizedBgpExtendedMessageCapability(open1));
     }
-
-    @Test(expected=UnsupportedOperationException.class)
-    public void testAsNumberUtilPrivateConstructor() throws Throwable {
-        final Constructor<AsNumberUtil> c = AsNumberUtil.class.getDeclaredConstructor();
-        c.setAccessible(true);
-        try {
-            c.newInstance();
-        } catch (final InvocationTargetException e) {
-            throw e.getCause();
-        }
-    }
 }
index 3dc34f3b4c120f64a493efc11c446ab78e90b016..f10dc2715a349758e161bf1a76e6b8bb07a9b427 100644 (file)
@@ -22,8 +22,10 @@ public class TableTypeTest {
 
     @Test
     public void testTableTypes() {
-        final BgpTableType tt1 = new BgpTableTypeImpl(Ipv4AddressFamily.class, MplsLabeledVpnSubsequentAddressFamily.class);
-        final BgpTableType tt2 = new BgpTableTypeImpl(Ipv6AddressFamily.class, MplsLabeledVpnSubsequentAddressFamily.class);
+        final BgpTableType tt1 = new BgpTableTypeImpl(Ipv4AddressFamily.class,
+                MplsLabeledVpnSubsequentAddressFamily.class);
+        final BgpTableType tt2 = new BgpTableTypeImpl(Ipv6AddressFamily.class,
+                MplsLabeledVpnSubsequentAddressFamily.class);
 
         try {
             new BgpTableTypeImpl(null, MplsLabeledVpnSubsequentAddressFamily.class);
index 03ef590db345b679cdf5d127be0ef72fc199daef..9c2166ce3a129be5a9f0a56a6d9ec47d1d8a3754 100644 (file)
         </dependency>
     </dependencies>
 
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-checkstyle-plugin</artifactId>
+                <configuration>
+                    <propertyExpansion>checkstyle.violationSeverity=error</propertyExpansion>
+                </configuration>
+            </plugin>
+            <plugin>
+                <groupId>org.codehaus.mojo</groupId>
+                <artifactId>findbugs-maven-plugin</artifactId>
+                <configuration>
+                    <failOnError>true</failOnError>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+
     <scm>
         <connection>scm:git:ssh://git.opendaylight.org:29418/bgpcep.git</connection>
         <developerConnection>scm:git:ssh://git.opendaylight.org:29418/bgpcep.git</developerConnection>
index 6347efd850bbc452d1ca64dd11a0b5a417575cbc..38d73508c681375c9bc0323d16a9a0a62392b1e8 100644 (file)
@@ -13,9 +13,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.bgp.rib.RibKey;
 import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier;
 
-/**
- *
- */
 public class DefaultRibReference implements RibReference {
     private final KeyedInstanceIdentifier<Rib, RibKey> instanceIdentifier;
 
index 8a93db673eeeec1f10510d956e9e0f9e63b4d399..9cc65baf83c89c2b68dc1099c64d97d7621989d1 100644 (file)
@@ -17,6 +17,7 @@ import java.util.Map;
 import java.util.Set;
 import java.util.concurrent.atomic.LongAdder;
 import javax.annotation.Nonnull;
+import javax.annotation.concurrent.GuardedBy;
 import javax.annotation.concurrent.NotThreadSafe;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.controller.md.sal.dom.api.ClusteredDOMDataTreeChangeListener;
@@ -65,12 +66,12 @@ final class LocRibWriter implements AutoCloseable, TotalPrefixesCounter, TotalPa
 
     private static final Logger LOG = LoggerFactory.getLogger(LocRibWriter.class);
 
-    private static final LeafNode<Boolean> ATTRIBUTES_UPTODATE_TRUE = ImmutableNodes.leafNode(QName.create(Attributes.QNAME, "uptodate"), Boolean.TRUE);
+    private static final LeafNode<Boolean> ATTRIBUTES_UPTODATE_TRUE = ImmutableNodes
+            .leafNode(QName.create(Attributes.QNAME, "uptodate"), Boolean.TRUE);
 
     private final Map<PathArgument, RouteEntry> routeEntries = new HashMap<>();
     private final YangInstanceIdentifier locRibTarget;
     private final NodeIdentifierWithPredicates tableKey;
-    private DOMTransactionChain chain;
     private final ExportPolicyPeerTracker exportPolicyPeerTracker;
     private final NodeIdentifier attributesIdentifier;
     private final Long ourAs;
@@ -78,10 +79,12 @@ final class LocRibWriter implements AutoCloseable, TotalPrefixesCounter, TotalPa
     private final TablesKey localTablesKey;
     private final YangInstanceIdentifier target;
     private final DOMDataTreeChangeService service;
-    private ListenerRegistration<LocRibWriter> reg;
     private final PathSelectionMode pathSelectionMode;
     private final LongAdder totalPathsCounter = new LongAdder();
     private final LongAdder totalPrefixesCounter = new LongAdder();
+    private DOMTransactionChain chain;
+    @GuardedBy("this")
+    private ListenerRegistration<LocRibWriter> reg;
 
     private LocRibWriter(final RIBSupportContextRegistry registry, final DOMTransactionChain chain,
         final YangInstanceIdentifier target, final Long ourAs, final DOMDataTreeChangeService service,
@@ -116,12 +119,16 @@ final class LocRibWriter implements AutoCloseable, TotalPrefixesCounter, TotalPa
         this.reg = this.service.registerDataTreeChangeListener(wildcard, this);
     }
 
-    public static LocRibWriter create(@Nonnull final RIBSupportContextRegistry registry, @Nonnull final TablesKey tablesKey,
-        @Nonnull final DOMTransactionChain chain,
-        @Nonnull final YangInstanceIdentifier target, @Nonnull final AsNumber ourAs, @Nonnull final DOMDataTreeChangeService service,
-        @Nonnull final ExportPolicyPeerTracker ep, @Nonnull final PathSelectionMode pathSelectionStrategy) {
+    public static LocRibWriter create(@Nonnull final RIBSupportContextRegistry registry,
+            @Nonnull final TablesKey tablesKey,
+            @Nonnull final DOMTransactionChain chain,
+            @Nonnull final YangInstanceIdentifier target,
+            @Nonnull final AsNumber ourAs,
+            @Nonnull final DOMDataTreeChangeService service,
+            @Nonnull final ExportPolicyPeerTracker ep,
+            @Nonnull final PathSelectionMode pathSelectionStrategy) {
         return new LocRibWriter(registry, chain, target, ourAs.getValue(), service, ep, tablesKey,
-            pathSelectionStrategy);
+                pathSelectionStrategy);
     }
 
     /**
@@ -137,9 +144,11 @@ final class LocRibWriter implements AutoCloseable, TotalPrefixesCounter, TotalPa
     }
 
     @Override
-    public void close() {
-        this.reg.close();
-        this.reg = null;
+    public synchronized void close() {
+        if (this.reg != null) {
+            this.reg.close();
+            this.reg = null;
+        }
         this.chain.close();
     }
 
@@ -176,7 +185,8 @@ final class LocRibWriter implements AutoCloseable, TotalPrefixesCounter, TotalPa
         }
     }
 
-    private Map<RouteUpdateKey, RouteEntry> update(final DOMDataWriteTransaction tx, final Collection<DataTreeCandidate> changes) {
+    private Map<RouteUpdateKey, RouteEntry> update(final DOMDataWriteTransaction tx,
+            final Collection<DataTreeCandidate> changes) {
         final Map<RouteUpdateKey, RouteEntry> ret = new HashMap<>();
         changes.forEach(tc -> {
             final DataTreeCandidateNode table = tc.getRootNode();
@@ -188,7 +198,8 @@ final class LocRibWriter implements AutoCloseable, TotalPrefixesCounter, TotalPa
         return ret;
     }
 
-    private void initializeTableWithExistentRoutes(final DataTreeCandidateNode table, final PeerId peerIdOfNewPeer, final YangInstanceIdentifier rootPath,
+    private void initializeTableWithExistentRoutes(final DataTreeCandidateNode table, final PeerId peerIdOfNewPeer,
+            final YangInstanceIdentifier rootPath,
         final DOMDataWriteTransaction tx) {
         if (!table.getDataBefore().isPresent() && this.exportPolicyPeerTracker.isTableSupported(peerIdOfNewPeer)) {
             this.exportPolicyPeerTracker.registerPeerAsInitialized(peerIdOfNewPeer);
@@ -209,7 +220,8 @@ final class LocRibWriter implements AutoCloseable, TotalPrefixesCounter, TotalPa
                 if (child.getDataAfter().isPresent()) {
                     // putting uptodate attribute in
                     LOG.trace("Uptodate found for {}", child.getDataAfter());
-                    tx.put(LogicalDatastoreType.OPERATIONAL, this.locRibTarget.node(child.getIdentifier()), child.getDataAfter().get());
+                    tx.put(LogicalDatastoreType.OPERATIONAL, this.locRibTarget.node(child.getIdentifier()),
+                            child.getDataAfter().get());
                 }
                 continue;
             }
@@ -217,7 +229,8 @@ final class LocRibWriter implements AutoCloseable, TotalPrefixesCounter, TotalPa
         }
     }
 
-    private void updateRoutesEntries(final DataTreeCandidateNode child, final PeerId peerId, final Map<RouteUpdateKey, RouteEntry> routes) {
+    private void updateRoutesEntries(final DataTreeCandidateNode child, final PeerId peerId,
+            final Map<RouteUpdateKey, RouteEntry> routes) {
         final UnsignedInteger routerId = RouterIds.routerIdForPeerId(peerId);
         final Collection<DataTreeCandidateNode> modifiedRoutes = this.ribSupport.changedRoutes(child);
         for (final DataTreeCandidateNode route : modifiedRoutes) {
@@ -229,7 +242,8 @@ final class LocRibWriter implements AutoCloseable, TotalPrefixesCounter, TotalPa
                 if (entry == null) {
                     entry = createEntry(routeId);
                 }
-                entry.addRoute(routerId, this.ribSupport.extractPathId(maybeData.get()), this.attributesIdentifier, maybeData.get());
+                entry.addRoute(routerId, this.ribSupport.extractPathId(maybeData.get()),
+                        this.attributesIdentifier, maybeData.get());
                 this.totalPathsCounter.increment();
             } else if (entry != null) {
                 this.totalPathsCounter.decrement();
@@ -245,7 +259,8 @@ final class LocRibWriter implements AutoCloseable, TotalPrefixesCounter, TotalPa
         }
     }
 
-    private void walkThrough(final DOMDataWriteTransaction tx, final Set<Map.Entry<RouteUpdateKey, RouteEntry>> toUpdate) {
+    private void walkThrough(final DOMDataWriteTransaction tx,
+            final Set<Map.Entry<RouteUpdateKey, RouteEntry>> toUpdate) {
         for (final Map.Entry<RouteUpdateKey, RouteEntry> e : toUpdate) {
             LOG.trace("Walking through {}", e);
             final RouteEntry entry = e.getValue();
@@ -254,7 +269,8 @@ final class LocRibWriter implements AutoCloseable, TotalPrefixesCounter, TotalPa
                 LOG.trace("Best path has not changed, continuing");
                 continue;
             }
-            entry.updateRoute(this.localTablesKey, this.exportPolicyPeerTracker, this.locRibTarget, this.ribSupport, tx, e.getKey().getRouteId());
+            entry.updateRoute(this.localTablesKey, this.exportPolicyPeerTracker, this.locRibTarget,
+                    this.ribSupport, tx, e.getKey().getRouteId());
         }
     }
 
index 86298afa2792f04688038abe451a01e88f13961d..57a32fae3c1878a56d560eeb3d03998b37b4d677 100755 (executable)
@@ -100,6 +100,7 @@ public final class RIBImpl extends BGPRIBStateImpl implements RIB, TransactionCh
     private final YangInstanceIdentifier yangRibId;
     private final RIBSupportContextRegistryImpl ribContextRegistry;
     private final CodecsRegistryImpl codecsRegistry;
+    @GuardedBy("this")
     private ClusterSingletonServiceRegistration registration;
     private final DOMDataBrokerExtension service;
     private final Map<TransactionChain<?, ?>, LocRibWriter> txChainToLocRibWriter = new HashMap<>();
index 376a2ce0003d445565b0da206959a19012fdc7aa..f9a7b9a4f6b78f512ac02b3bf17662ac85f27c3f 100755 (executable)
@@ -26,6 +26,7 @@ public interface BGPDispatcher{
      * @param retryTimer Retry timer
      * @return Future promising a client session
      */
+    @Deprecated
     Future<? extends BGPSession> createClient(InetSocketAddress remoteAddress, int retryTimer);
 
     /**
index c806736d382b24125b3ad3435d5e6a30e114ce0c..538a2a254446deeaf803f51c1c4fe15503e31cf2 100644 (file)
 
     <build>
         <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-checkstyle-plugin</artifactId>
+                <configuration>
+                    <propertyExpansion>checkstyle.violationSeverity=error</propertyExpansion>
+                </configuration>
+            </plugin>
+            <plugin>
+                <groupId>org.codehaus.mojo</groupId>
+                <artifactId>findbugs-maven-plugin</artifactId>
+                <configuration>
+                    <failOnError>true</failOnError>
+                </configuration>
+            </plugin>
             <plugin>
                 <groupId>org.apache.maven.plugins</groupId>
                 <artifactId>maven-jar-plugin</artifactId>
index 20f5dc0d7e81f146d8c089dd6df7f7737b828202..040e3abd920125298ae3283d405c0de9a784494e 100644 (file)
@@ -37,18 +37,19 @@ final class Arguments implements ArgumentsInput {
     private static final int INITIAL_HOLD_TIME = 90;
     private static final String LOG_LEVEL = "log_level";
     private static final String REMOTE_ADDRESS_PARAMETER = "remoteAddress";
-    private static final String REMOTE_ADDRESS_PARAMETER_HELP = "IP address of remote BGP peer, which the tool can accept or initiate connect to that " +
-        "address (based on the mode)";
+    private static final String REMOTE_ADDRESS_PARAMETER_HELP = "IP address of remote BGP peer, which the tool"
+            + " can accept or initiate connect to that address (based on the mode)";
     private static final String LOCAL_ADDRESS_PARAMETER = "localAddress";
     private static final String LOCAL_ADDRESS_PARAMETER_HELP = "IP address of BGP speakers which the tools simulates";
     private static final String EXTENDED_COMMUNITIES_PARAMETER = "extended_communities";
-    private static final String EXTENDED_COMMUNITIES_PARAMETER_HELP = "Extended communities to be send. Format: x,x,x where x is each extended " +
-        "community from bgp-types.yang as as-4-generic-spec-extended-community, link-bandwidth-extended-community, ...";
+    private static final String EXTENDED_COMMUNITIES_PARAMETER_HELP = "Extended communities to be send. "
+            + "Format: x,x,x where x is each extended community from bgp-types.yang as "
+            + "as-4-generic-spec-extended-community, link-bandwidth-extended-community, ...";
     private static final String ACTIVE_CONNECTION_PARAMETER = "active";
     private static final String ACTIVE_CONNECTION_HELP = "Active initialization of the connection, by default false";
     private static final String HOLD_TIMER_PARAMETER = "holdtimer";
-    private static final String INITIAL_HOLD_TIME_HELP = "In seconds, value of the desired holdtimer. According to RFC4271, recommended value for " +
-        "deadtimer is 90 seconds(set by default)";
+    private static final String INITIAL_HOLD_TIME_HELP = "In seconds, value of the desired holdtimer."
+            + " According to RFC4271, recommended value for deadtimer is 90 seconds(set by default)";
     private static final String PREFIXES_PARAMETER = "prefixes";
     private static final String PREFIXES_PARAMETER_HELP = "Number of prefixes to be sent";
     private static final String MULTIPATH_PARAMETER = "multiPathSupport";
@@ -56,8 +57,8 @@ final class Arguments implements ArgumentsInput {
     private static final String AS_PARAMETER = "as";
     private static final String AS_PARAMETER_HELP = "Value of AS in the initial open message";
     private static final String SPEAKERS_COUNT = "speakersCount";
-    private static final String SPEAKERS_COUNT_HELP = "Number of simulated BGP speakers, when creating each speaker, use incremented " +
-        "local-address for binding";
+    private static final String SPEAKERS_COUNT_HELP = "Number of simulated BGP speakers, when creating each speaker,"
+            + " use incremented local-address for binding";
     private static final ArgumentParser ARGUMENT_PARSER = initializeArgumentParser();
     private final Namespace parseArgs;
 
@@ -85,21 +86,34 @@ final class Arguments implements ArgumentsInput {
     private static ArgumentParser initializeArgumentParser() {
         final ArgumentParser parser = ArgumentParsers.newArgumentParser(PROGRAM_NAME);
 
-        parser.addArgument("-i", toArgName(ACTIVE_CONNECTION_PARAMETER)).type(Boolean.class).setDefault(false).help(ACTIVE_CONNECTION_HELP);
-        parser.addArgument("-ho", toArgName(HOLD_TIMER_PARAMETER)).type(Integer.class).setDefault(INITIAL_HOLD_TIME).help(INITIAL_HOLD_TIME_HELP);
-        parser.addArgument("-pr", toArgName(PREFIXES_PARAMETER)).type(Integer.class).setDefault(0).help(PREFIXES_PARAMETER_HELP);
-        parser.addArgument("-sc", toArgName(SPEAKERS_COUNT)).type(Integer.class).setDefault(0).help(SPEAKERS_COUNT_HELP);
-        parser.addArgument("-mp", toArgName(MULTIPATH_PARAMETER)).type(Boolean.class).setDefault(false).help(MULTIPATH_PARAMETER_HELP);
-        parser.addArgument("-" + AS_PARAMETER, toArgName(AS_PARAMETER)).type((ArgumentTypeTool<AsNumber>) as -> new AsNumber(Long.valueOf(as)))
-            .setDefault(new AsNumber(64496L)).help(AS_PARAMETER_HELP);
-        parser.addArgument("-ec", toArgName(EXTENDED_COMMUNITIES_PARAMETER)).type((ArgumentTypeTool<List<String>>) extComInput ->
-            Arrays.asList(extComInput.split(","))).setDefault(Collections.emptyList()).help(EXTENDED_COMMUNITIES_PARAMETER_HELP);
-        parser.addArgument("-ll", toArgName(LOG_LEVEL)).type((ArgumentTypeTool<Level>) Level::toLevel).setDefault(Level.INFO).help("log levels");
-        parser.addArgument("-ra", toArgName(REMOTE_ADDRESS_PARAMETER)).type((ArgumentTypeTool<List<InetSocketAddress>>) input ->
-            InetSocketAddressUtil.parseAddresses(input, DEFAULT_REMOTE_PORT)).setDefault(Collections.singletonList(REMOTE_ADDRESS))
-            .help(REMOTE_ADDRESS_PARAMETER_HELP);
-        parser.addArgument("-la", toArgName(LOCAL_ADDRESS_PARAMETER)).type((ArgumentTypeTool<InetSocketAddress>) input ->
-            getInetSocketAddress(input, DEFAULT_LOCAL_PORT)).setDefault(LOCAL_ADDRESS).help(LOCAL_ADDRESS_PARAMETER_HELP);
+        parser.addArgument("-i", toArgName(ACTIVE_CONNECTION_PARAMETER)).type(Boolean.class)
+                .setDefault(false).help(ACTIVE_CONNECTION_HELP);
+        parser.addArgument("-ho", toArgName(HOLD_TIMER_PARAMETER)).type(Integer.class)
+                .setDefault(INITIAL_HOLD_TIME).help(INITIAL_HOLD_TIME_HELP);
+        parser.addArgument("-pr", toArgName(PREFIXES_PARAMETER)).type(Integer.class)
+                .setDefault(0).help(PREFIXES_PARAMETER_HELP);
+        parser.addArgument("-sc", toArgName(SPEAKERS_COUNT)).type(Integer.class)
+                .setDefault(0).help(SPEAKERS_COUNT_HELP);
+        parser.addArgument("-mp", toArgName(MULTIPATH_PARAMETER)).type(Boolean.class)
+                .setDefault(false).help(MULTIPATH_PARAMETER_HELP);
+        parser.addArgument("-" + AS_PARAMETER, toArgName(AS_PARAMETER))
+                .type((ArgumentTypeTool<AsNumber>) as -> new AsNumber(Long.valueOf(as)))
+                .setDefault(new AsNumber(64496L)).help(AS_PARAMETER_HELP);
+        parser.addArgument("-ec", toArgName(EXTENDED_COMMUNITIES_PARAMETER))
+                .type((ArgumentTypeTool<List<String>>) extComInput ->
+                        Arrays.asList(extComInput.split(","))).setDefault(Collections.emptyList())
+                .help(EXTENDED_COMMUNITIES_PARAMETER_HELP);
+        parser.addArgument("-ll", toArgName(LOG_LEVEL))
+                .type((ArgumentTypeTool<Level>) Level::toLevel).setDefault(Level.INFO).help("log levels");
+        parser.addArgument("-ra", toArgName(REMOTE_ADDRESS_PARAMETER))
+                .type((ArgumentTypeTool<List<InetSocketAddress>>) input ->
+                        InetSocketAddressUtil.parseAddresses(input, DEFAULT_REMOTE_PORT))
+                .setDefault(Collections.singletonList(REMOTE_ADDRESS))
+                .help(REMOTE_ADDRESS_PARAMETER_HELP);
+        parser.addArgument("-la", toArgName(LOCAL_ADDRESS_PARAMETER))
+                .type((ArgumentTypeTool<InetSocketAddress>) input ->
+                        getInetSocketAddress(input, DEFAULT_LOCAL_PORT))
+                .setDefault(LOCAL_ADDRESS).help(LOCAL_ADDRESS_PARAMETER_HELP);
         return parser;
     }
 
index 6a5f25621f3aa8fea34dd7a3cb670e3ddd5c45e3..d09f56a73892d05745380b44c99b731b73e175ed 100644 (file)
@@ -34,24 +34,24 @@ final class BGPPeerBuilder {
     }
 
     static void createPeer(final BGPDispatcher dispatcher, final Arguments arguments,
-        final InetSocketAddress localAddress, final BGPSessionListener sessionListener,
-        final BgpParameters bgpParameters) {
+            final InetSocketAddress localAddress, final BGPSessionListener sessionListener,
+            final BgpParameters bgpParameters) {
         final AsNumber as = arguments.getAs();
         final BGPSessionPreferences proposal = new BGPSessionPreferences(as, arguments.getHoldTimer(),
-            new BgpId(localAddress.getAddress().getHostAddress()), as, Collections.singletonList(bgpParameters),
-            Optional.absent());
+                new BgpId(localAddress.getAddress().getHostAddress()), as, Collections.singletonList(bgpParameters),
+                Optional.absent());
         final BGPPeerRegistry strictBGPPeerRegistry = dispatcher.getBGPPeerRegistry();
         if (arguments.getInitiateConnection()) {
             for (final InetSocketAddress remoteAddress : arguments.getRemoteAddresses()) {
                 strictBGPPeerRegistry.addPeer(StrictBGPPeerRegistry.getIpAddress(remoteAddress), sessionListener,
-                    proposal);
+                        proposal);
                 addFutureListener(localAddress, ((BGPDispatcherImpl) dispatcher).createClient(localAddress,
-                    remoteAddress, RETRY_TIMER, true));
+                        remoteAddress, RETRY_TIMER, true));
             }
         } else {
             for (final InetSocketAddress remoteAddress : arguments.getRemoteAddresses()) {
                 strictBGPPeerRegistry.addPeer(StrictBGPPeerRegistry.getIpAddress(remoteAddress), sessionListener,
-                    proposal);
+                        proposal);
             }
             addFutureListener(localAddress, dispatcher.createServer(localAddress));
         }
@@ -60,6 +60,6 @@ final class BGPPeerBuilder {
 
     private static <T> void addFutureListener(final InetSocketAddress localAddress, final Future<T> future) {
         future.addListener(future1 -> Preconditions.checkArgument(future1.isSuccess(),
-            "Unable to start bgp session on %s", localAddress, future1.cause()));
+                "Unable to start bgp session on %s", localAddress, future1.cause()));
     }
 }
index 95f9c1c5874b10659bf00869e31dbd04a787a39e..20e63cc3153316a77cecdb5970a4f558a7fb683d 100644 (file)
@@ -54,8 +54,10 @@ final class BGPTestTool {
     void start(final Arguments arguments) {
         final BGPDispatcher dispatcher = initializeActivator();
 
-        final ArrayList<OptionalCapabilities> optCap = Lists.newArrayList(createMPCapability(Ipv4AddressFamily.class, UnicastSubsequentAddressFamily.class),
-            createMPCapability(LinkstateAddressFamily.class, LinkstateSubsequentAddressFamily.class), createAs4BytesMPCapability(arguments.getAs()));
+        final ArrayList<OptionalCapabilities> optCap = Lists.newArrayList(createMPCapability(Ipv4AddressFamily.class,
+                UnicastSubsequentAddressFamily.class),
+            createMPCapability(LinkstateAddressFamily.class, LinkstateSubsequentAddressFamily.class),
+                createAs4BytesMPCapability(arguments.getAs()));
         if (arguments.getMultiPathSupport()) {
             optCap.add(createAddPathCapability());
         }
@@ -66,7 +68,8 @@ final class BGPTestTool {
         InetAddress address = localAddress.getAddress();
         int numberOfSpeakers = arguments.getSpeakerCount();
         do {
-            final BGPSessionListener sessionListener = new TestingListener(arguments.getNumberOfPrefixes(), arguments.getExtendedCommunities(),
+            final BGPSessionListener sessionListener = new TestingListener(arguments.getNumberOfPrefixes(),
+                    arguments.getExtendedCommunities(),
                 arguments.getMultiPathSupport());
             this.listeners.put(address.getHostAddress(), sessionListener);
             createPeer(dispatcher, arguments, new InetSocketAddress(address, port), sessionListener, bgpParameters);
@@ -80,33 +83,42 @@ final class BGPTestTool {
         final BGPExtensionProviderContext ctx = ServiceLoaderBGPExtensionProviderContext.getSingletonInstance();
         activator.start(ctx);
 
-        final org.opendaylight.protocol.bgp.inet.BGPActivator inetActivator = new org.opendaylight.protocol.bgp.inet.BGPActivator();
+        final org.opendaylight.protocol.bgp.inet.BGPActivator inetActivator
+                = new org.opendaylight.protocol.bgp.inet.BGPActivator();
         inetActivator.start(ctx);
 
-        final org.opendaylight.protocol.bgp.evpn.impl.BGPActivator evpnActivator = new org.opendaylight.protocol.bgp.evpn.impl.BGPActivator();
+        final org.opendaylight.protocol.bgp.evpn.impl.BGPActivator evpnActivator = new org.opendaylight.protocol.bgp
+                .evpn.impl.BGPActivator();
         evpnActivator.start(ctx);
 
         final SimpleFlowspecExtensionProviderContext fsContext = new SimpleFlowspecExtensionProviderContext();
         final FlowspecActivator flowspecActivator = new FlowspecActivator(fsContext);
-        final org.opendaylight.protocol.bgp.flowspec.BGPActivator flowspecBGPActivator = new org.opendaylight.protocol.bgp.flowspec.BGPActivator(flowspecActivator);
+        final org.opendaylight.protocol.bgp.flowspec.BGPActivator flowspecBGPActivator
+                = new org.opendaylight.protocol.bgp.flowspec.BGPActivator(flowspecActivator);
         flowspecBGPActivator.start(ctx);
 
-        final org.opendaylight.protocol.bgp.labeled.unicast.BGPActivator labeledActivator = new org.opendaylight.protocol.bgp.labeled.unicast.BGPActivator();
+        final org.opendaylight.protocol.bgp.labeled.unicast.BGPActivator labeledActivator
+                = new org.opendaylight.protocol.bgp.labeled.unicast.BGPActivator();
         labeledActivator.start(ctx);
 
-        final org.opendaylight.protocol.bgp.l3vpn.ipv4.BgpIpv4Activator bgpIpv4Activator = new org.opendaylight.protocol.bgp.l3vpn.ipv4.BgpIpv4Activator();
+        final org.opendaylight.protocol.bgp.l3vpn.ipv4.BgpIpv4Activator bgpIpv4Activator
+                = new org.opendaylight.protocol.bgp.l3vpn.ipv4.BgpIpv4Activator();
         bgpIpv4Activator.start(ctx);
 
-        final org.opendaylight.protocol.bgp.l3vpn.ipv6.BgpIpv6Activator bgpIpv6Activator = new org.opendaylight.protocol.bgp.l3vpn.ipv6.BgpIpv6Activator();
+        final org.opendaylight.protocol.bgp.l3vpn.ipv6.BgpIpv6Activator bgpIpv6Activator
+                = new org.opendaylight.protocol.bgp.l3vpn.ipv6.BgpIpv6Activator();
         bgpIpv6Activator.start(ctx);
 
         return new BGPDispatcherImpl(ctx.getMessageRegistry(), new NioEventLoopGroup(), new NioEventLoopGroup(),
             new StrictBGPPeerRegistry());
     }
 
-    private static OptionalCapabilities createMPCapability(final Class<? extends AddressFamily> afi, final Class<? extends SubsequentAddressFamily> safi) {
-        return new OptionalCapabilitiesBuilder().setCParameters(new CParametersBuilder().addAugmentation(CParameters1.class, new CParameters1Builder()
-            .setMultiprotocolCapability(new MultiprotocolCapabilityBuilder().setAfi(afi).setSafi(safi).build()).build()).build()).build();
+    private static OptionalCapabilities createMPCapability(final Class<? extends AddressFamily> afi,
+            final Class<? extends SubsequentAddressFamily> safi) {
+        return new OptionalCapabilitiesBuilder().setCParameters(new CParametersBuilder()
+                .addAugmentation(CParameters1.class, new CParameters1Builder()
+            .setMultiprotocolCapability(new MultiprotocolCapabilityBuilder().setAfi(afi)
+                    .setSafi(safi).build()).build()).build()).build();
     }
 
     private static OptionalCapabilities createAs4BytesMPCapability(final AsNumber as) {
@@ -119,10 +131,13 @@ final class BGPTestTool {
     }
 
     private static OptionalCapabilities createAddPathCapability() {
-        return new OptionalCapabilitiesBuilder().setCParameters(new CParametersBuilder().addAugmentation(CParameters1.class, new CParameters1Builder()
-            .setAddPathCapability(new AddPathCapabilityBuilder().setAddressFamilies(Lists.newArrayList(new AddressFamiliesBuilder()
-                .setAfi(Ipv4AddressFamily.class).setSafi(UnicastSubsequentAddressFamily.class).setSendReceive(SendReceive.Both).build()
-            )).build()).build()).build()).build();
+        return new OptionalCapabilitiesBuilder().setCParameters(new CParametersBuilder()
+                .addAugmentation(CParameters1.class, new CParameters1Builder()
+                        .setAddPathCapability(new AddPathCapabilityBuilder()
+                                .setAddressFamilies(Lists.newArrayList(new AddressFamiliesBuilder()
+                                        .setAfi(Ipv4AddressFamily.class)
+                                        .setSafi(UnicastSubsequentAddressFamily.class)
+                                        .setSendReceive(SendReceive.Both).build())).build()).build()).build()).build();
     }
 
     void printCount(final String localAddress) {
index 8aaf2f94f37071aaaeb245bc28e4df9788b7a4df..0df1f4ced5fa43877929d3538a85d716d290271c 100644 (file)
@@ -47,7 +47,8 @@ import org.slf4j.LoggerFactory;
 
 final class CommunitiesBuilder {
     private static final Logger LOG = LoggerFactory.getLogger(CommunitiesBuilder.class);
-    private static final As4SpecificCommon AS_4_COMMON = new As4SpecificCommonBuilder().setAsNumber(new AsNumber(20L)).setLocalAdministrator(100).build();
+    private static final As4SpecificCommon AS_4_COMMON = new As4SpecificCommonBuilder()
+            .setAsNumber(new AsNumber(20L)).setLocalAdministrator(100).build();
     private static final Ipv4Address IPV4 = new Ipv4Address("192.168.1.0");
     private static final byte[] BYTE = new byte[]{(byte) 0x4f, (byte) 0x70, (byte) 0x00, (byte) 0x00};
     private static final int LA = 4660;
@@ -62,101 +63,107 @@ final class CommunitiesBuilder {
         for (String ec : extCom) {
             ExtendedCommunity community = null;
             switch (ec) {
-            case "as-4-generic-spec-extended-community":
-                community = CommunitiesBuilder.as4GenSpecBuild();
-                break;
-            case "as-4-route-target-extended-community":
-                community = CommunitiesBuilder.as4RTBuild();
-                break;
-            case "as-4-route-origin-extended-community":
-                community = CommunitiesBuilder.as4ROBuild();
-                break;
-            case "route-origin":
-                community = CommunitiesBuilder.rOBuild();
-                break;
-            case "route-target":
-                community = CommunitiesBuilder.rTBuild();
-                break;
-            case "route-origin-extended-community":
-                community = CommunitiesBuilder.rOECBuild();
-                break;
-            case "route-target-extended-community":
-                community = CommunitiesBuilder.rTECBuild();
-                break;
-            case "link-bandwidth-extended-community":
-                community = CommunitiesBuilder.linkBandBuild();
-                break;
-            case "opaque-extended-community":
-                community = CommunitiesBuilder.opaqueBuild();
-                break;
-            case "inet4-specific-extended-community":
-                community = CommunitiesBuilder.inet4Build();
-                break;
-            case "as-specific-extended-community":
-                community = CommunitiesBuilder.asSpecBuild();
-                break;
-            default:
-                LOG.debug("Not recognized Extended Community {}", ec);
-                break;
+                case "as-4-generic-spec-extended-community":
+                    community = CommunitiesBuilder.as4GenSpecBuild();
+                    break;
+                case "as-4-route-target-extended-community":
+                    community = CommunitiesBuilder.as4RTBuild();
+                    break;
+                case "as-4-route-origin-extended-community":
+                    community = CommunitiesBuilder.as4ROBuild();
+                    break;
+                case "route-origin":
+                    community = CommunitiesBuilder.rOBuild();
+                    break;
+                case "route-target":
+                    community = CommunitiesBuilder.rTBuild();
+                    break;
+                case "route-origin-extended-community":
+                    community = CommunitiesBuilder.rOECBuild();
+                    break;
+                case "route-target-extended-community":
+                    community = CommunitiesBuilder.rTECBuild();
+                    break;
+                case "link-bandwidth-extended-community":
+                    community = CommunitiesBuilder.linkBandBuild();
+                    break;
+                case "opaque-extended-community":
+                    community = CommunitiesBuilder.opaqueBuild();
+                    break;
+                case "inet4-specific-extended-community":
+                    community = CommunitiesBuilder.inet4Build();
+                    break;
+                case "as-specific-extended-community":
+                    community = CommunitiesBuilder.asSpecBuild();
+                    break;
+                default:
+                    LOG.debug("Not recognized Extended Community {}", ec);
+                    break;
             }
-            extendedCommunities.add(new ExtendedCommunitiesBuilder().setTransitive(true).setExtendedCommunity(community).build());
+            extendedCommunities.add(new ExtendedCommunitiesBuilder()
+                    .setTransitive(true).setExtendedCommunity(community).build());
         }
         return extendedCommunities;
     }
 
     private static ExtendedCommunity as4GenSpecBuild() {
         return new As4GenericSpecExtendedCommunityCaseBuilder()
-            .setAs4GenericSpecExtendedCommunity(new As4GenericSpecExtendedCommunityBuilder()
-                .setAs4SpecificCommon(AS_4_COMMON).build()).build();
+                .setAs4GenericSpecExtendedCommunity(new As4GenericSpecExtendedCommunityBuilder()
+                        .setAs4SpecificCommon(AS_4_COMMON).build()).build();
     }
 
     private static ExtendedCommunity as4RTBuild() {
         return new As4RouteTargetExtendedCommunityCaseBuilder().setAs4RouteTargetExtendedCommunity(
-            new As4RouteTargetExtendedCommunityBuilder().setAs4SpecificCommon(AS_4_COMMON).build()).build();
+                new As4RouteTargetExtendedCommunityBuilder().setAs4SpecificCommon(AS_4_COMMON).build()).build();
     }
 
     private static ExtendedCommunity as4ROBuild() {
         return new As4RouteOriginExtendedCommunityCaseBuilder().setAs4RouteOriginExtendedCommunity(
-            new As4RouteOriginExtendedCommunityBuilder().setAs4SpecificCommon(AS_4_COMMON).build()).build();
+                new As4RouteOriginExtendedCommunityBuilder().setAs4SpecificCommon(AS_4_COMMON).build()).build();
     }
 
     private static ExtendedCommunity rTBuild() {
         return new RouteTargetIpv4CaseBuilder().setRouteTargetIpv4(
-            new RouteTargetIpv4Builder().setGlobalAdministrator(IPV4).setLocalAdministrator(LA).build()).build();
+                new RouteTargetIpv4Builder().setGlobalAdministrator(IPV4).setLocalAdministrator(LA).build()).build();
     }
 
     private static ExtendedCommunity rOBuild() {
         return new RouteOriginIpv4CaseBuilder().setRouteOriginIpv4(
-            new RouteOriginIpv4Builder().setGlobalAdministrator(IPV4).setLocalAdministrator(LA).build()).build();
+                new RouteOriginIpv4Builder().setGlobalAdministrator(IPV4).setLocalAdministrator(LA).build()).build();
     }
 
     private static ExtendedCommunity linkBandBuild() {
-        return new LinkBandwidthCaseBuilder().setLinkBandwidthExtendedCommunity(new LinkBandwidthExtendedCommunityBuilder()
-            .setBandwidth(new Bandwidth(new Float32(BYTE))).build()).build();
+        return new LinkBandwidthCaseBuilder()
+                .setLinkBandwidthExtendedCommunity(new LinkBandwidthExtendedCommunityBuilder()
+                .setBandwidth(new Bandwidth(new Float32(BYTE))).build()).build();
     }
 
     private static ExtendedCommunity rOECBuild() {
         return new RouteOriginExtendedCommunityCaseBuilder().setRouteOriginExtendedCommunity(
-            new RouteOriginExtendedCommunityBuilder().setGlobalAdministrator(SHORT_AS).setLocalAdministrator(BYTE).build()).build();
+                new RouteOriginExtendedCommunityBuilder().setGlobalAdministrator(SHORT_AS)
+                        .setLocalAdministrator(BYTE).build()).build();
     }
 
     private static ExtendedCommunity rTECBuild() {
         return new RouteTargetExtendedCommunityCaseBuilder().setRouteTargetExtendedCommunity(
-            new RouteTargetExtendedCommunityBuilder().setGlobalAdministrator(SHORT_AS).setLocalAdministrator(BYTE).build()).build();
+                new RouteTargetExtendedCommunityBuilder().setGlobalAdministrator(SHORT_AS)
+                        .setLocalAdministrator(BYTE).build()).build();
     }
 
     private static ExtendedCommunity opaqueBuild() {
         return new OpaqueExtendedCommunityCaseBuilder().setOpaqueExtendedCommunity(
-            new OpaqueExtendedCommunityBuilder().setValue(BYTE).build()).build();
+                new OpaqueExtendedCommunityBuilder().setValue(BYTE).build()).build();
     }
 
     private static ExtendedCommunity inet4Build() {
         return new Inet4SpecificExtendedCommunityCaseBuilder().setInet4SpecificExtendedCommunity(
-            new Inet4SpecificExtendedCommunityBuilder().setGlobalAdministrator(IPV4).setLocalAdministrator(BYTE).build()).build();
+                new Inet4SpecificExtendedCommunityBuilder().setGlobalAdministrator(IPV4)
+                        .setLocalAdministrator(BYTE).build()).build();
     }
 
     private static ExtendedCommunity asSpecBuild() {
         return new AsSpecificExtendedCommunityCaseBuilder().setAsSpecificExtendedCommunity(
-            new AsSpecificExtendedCommunityBuilder().setGlobalAdministrator(SHORT_AS).setLocalAdministrator(BYTE).build()).build();
+                new AsSpecificExtendedCommunityBuilder().setGlobalAdministrator(SHORT_AS)
+                        .setLocalAdministrator(BYTE).build()).build();
     }
 }
index 6e9bb653484bbbbe8c2db3a73ba969e5367033c9..3c823fa5045e4b8cd9bd32980de90d176a0e00f9 100644 (file)
@@ -10,6 +10,7 @@ package org.opendaylight.protocol.bgp.testtool;
 import java.io.BufferedReader;
 import java.io.IOException;
 import java.io.InputStreamReader;
+import java.nio.charset.StandardCharsets;
 import org.opendaylight.protocol.util.LoggerUtil;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -29,7 +30,7 @@ public final class Main {
         LoggerUtil.initiateLogger(arguments);
 
         final BGPTestTool bgpTestTool = new BGPTestTool();
-        final InputStreamReader isr = new InputStreamReader(System.in);
+        final InputStreamReader isr = new InputStreamReader(System.in, StandardCharsets.UTF_8);
         final BufferedReader br = new BufferedReader(isr);
         bgpTestTool.start(arguments);
         for (;;) {
index 641a9ec6fd829d996774fd404cc6d62260dc0cb1..b8d4778f2600a5a4369376e5e6f343e7611f4c29 100644 (file)
@@ -43,30 +43,33 @@ final class PrefixesBuilder {
     private static final Ipv4NextHopCase NEXT_HOP;
 
     static {
-        NEXT_HOP = new Ipv4NextHopCaseBuilder().setIpv4NextHop(new Ipv4NextHopBuilder().setGlobal(new Ipv4Address("127.1.1.1")).build()).build();
+        NEXT_HOP = new Ipv4NextHopCaseBuilder().setIpv4NextHop(new Ipv4NextHopBuilder()
+                .setGlobal(new Ipv4Address("127.1.1.1")).build()).build();
     }
 
     private PrefixesBuilder() {
         throw new UnsupportedOperationException();
     }
 
-    static void advertiseIpv4Prefixes(final ChannelOutputLimiter session, final int nPrefixes, final List<String> extCom, final boolean multipartSupport) {
+    static void advertiseIpv4Prefixes(final ChannelOutputLimiter session, final int nprefixes,
+            final List<String> extCom, final boolean multipartSupport) {
         Ipv4Prefix addressPrefix = new Ipv4Prefix("1.1.1.1/31");
-        for (int i = 0; i < nPrefixes; i++) {
+        for (int i = 0; i < nprefixes; i++) {
             buildAndSend(session, addressPrefix, extCom, multipartSupport);
             addressPrefix = incrementIpv4Prefix(addressPrefix);
         }
     }
 
-    private static void buildAndSend(final ChannelOutputLimiter session, final Ipv4Prefix addressPrefix, final List<String> extCom,
-        final boolean multipartSupport) {
+    private static void buildAndSend(final ChannelOutputLimiter session, final Ipv4Prefix addressPrefix,
+            final List<String> extCom, final boolean multipartSupport) {
         final Update upd = new UpdateBuilder().setAttributes(createAttributes(extCom, multipartSupport, addressPrefix))
                 .build();
         session.write(upd);
         session.flush();
     }
 
-    private static Attributes createAttributes(final List<String> extCom, final boolean multiPathSupport, final Ipv4Prefix addressPrefix) {
+    private static Attributes createAttributes(final List<String> extCom, final boolean multiPathSupport,
+            final Ipv4Prefix addressPrefix) {
         final AttributesBuilder attBuilder = new AttributesBuilder();
         attBuilder.setOrigin(new OriginBuilder().setValue(BgpOrigin.Egp).build());
         attBuilder.setAsPath(new AsPathBuilder().setSegments(Collections.emptyList()).build());
@@ -80,10 +83,12 @@ final class PrefixesBuilder {
             prefixes.setPathId(new PathId(5L));
         }
         attBuilder.addAugmentation(Attributes1.class, new Attributes1Builder().setMpReachNlri(
-            new MpReachNlriBuilder().setCNextHop(NEXT_HOP).setAfi(Ipv4AddressFamily.class).setSafi(UnicastSubsequentAddressFamily.class)
-                .setAdvertizedRoutes(new AdvertizedRoutesBuilder().setDestinationType(
-                    new DestinationIpv4CaseBuilder().setDestinationIpv4(new DestinationIpv4Builder()
-                        .setIpv4Prefixes(Collections.singletonList(prefixes.build())).build()).build()).build()).build()).build());
+                new MpReachNlriBuilder().setCNextHop(NEXT_HOP).setAfi(Ipv4AddressFamily.class)
+                        .setSafi(UnicastSubsequentAddressFamily.class)
+                        .setAdvertizedRoutes(new AdvertizedRoutesBuilder().setDestinationType(
+                                new DestinationIpv4CaseBuilder().setDestinationIpv4(new DestinationIpv4Builder()
+                                        .setIpv4Prefixes(Collections.singletonList(prefixes.build())).build())
+                                        .build()).build()).build()).build());
 
         return attBuilder.build();
     }
index 457e6b7791de9a8c91c26681251e8e37afb13893..9bbc8ac76c7cb2035a6828413d894344a435ba06 100644 (file)
@@ -26,13 +26,13 @@ import org.slf4j.LoggerFactory;
  */
 final class TestingListener implements BGPSessionListener {
     private static final Logger LOG = LoggerFactory.getLogger(TestingListener.class);
-    private final int nPrefixes;
+    private final int nprefixes;
     private final List<String> extCom;
     private final boolean multiPathSupport;
     private LongAdder messageCounter = new LongAdder();
 
-    TestingListener(final int nPrefixes, final List<String> extCom, final boolean multiPathSupport) {
-        this.nPrefixes = nPrefixes;
+    TestingListener(final int nprefixes, final List<String> extCom, final boolean multiPathSupport) {
+        this.nprefixes = nprefixes;
         this.extCom = extCom;
         this.multiPathSupport = multiPathSupport;
     }
@@ -45,13 +45,15 @@ final class TestingListener implements BGPSessionListener {
     @Override
     public void onSessionUp(final BGPSession session) {
         LOG.info("Client Listener: Session Up.");
-        if (this.nPrefixes > 0) {
-            PrefixesBuilder.advertiseIpv4Prefixes(((BGPSessionImpl) session).getLimiter(), this.nPrefixes, this.extCom, this.multiPathSupport);
+        if (this.nprefixes > 0) {
+            PrefixesBuilder.advertiseIpv4Prefixes(((BGPSessionImpl) session).getLimiter(), this.nprefixes, this.extCom,
+                    this.multiPathSupport);
         }
     }
 
     @Override
-    public void onSessionDown(final BGPSession session, final Exception e) {
+    @SuppressWarnings("checkstyle:IllegalCatch")
+    public void onSessionDown(final BGPSession session, final Exception exc) {
         LOG.info("Client Listener: Connection lost.");
         try {
             session.close();
index 19d8f8326d789eb61a8581030bcf06f9261661de..9acd1e2a68b4ad0b912cd74dcdc44ff454cebf1e 100644 (file)
         </dependency>
     </dependencies>
 
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-checkstyle-plugin</artifactId>
+                <configuration>
+                    <propertyExpansion>checkstyle.violationSeverity=error</propertyExpansion>
+                </configuration>
+            </plugin>
+            <plugin>
+                <groupId>org.codehaus.mojo</groupId>
+                <artifactId>findbugs-maven-plugin</artifactId>
+                <configuration>
+                    <failOnError>true</failOnError>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+
     <scm>
         <connection>scm:git:ssh://git.opendaylight.org:29418/bgpcep.git</connection>
         <developerConnection>scm:git:ssh://git.opendaylight.org:29418/bgpcep.git</developerConnection>
index a7f3ac846449679075299b3850c0beadc38a719b..c98f60272d81d8ea17aa0749ad6151e604c549f7 100644 (file)
@@ -58,7 +58,8 @@ public final class BinaryBGPDumpFileParser {
                             // Parse length
                             final int length = ByteArray.bytesToInt(new byte[]{ byteArray[j], byteArray[j + 1] });
 
-                            Preconditions.checkArgument(length >= MINIMAL_LENGTH, "Invalid message at index " + start
+                            Preconditions.checkArgument(length >= MINIMAL_LENGTH,
+                                    "Invalid message at index " + start
                                     + ", length atribute is lower than " + MINIMAL_LENGTH);
 
                             final byte[] message = Arrays.copyOfRange(byteArray, start, start + length);
index 6f22c84274b8fa68eaa5399a2083e10e8feb5c76..e42f6b1f5dff0d16d07fe81e3d29957edf56f320 100644 (file)
@@ -21,6 +21,7 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.io.InputStreamReader;
 import java.util.List;
+import java.util.Locale;
 import javax.annotation.concurrent.Immutable;
 import org.opendaylight.protocol.util.ByteArray;
 import org.slf4j.Logger;
@@ -54,8 +55,8 @@ public final class HexDumpBGPFileParser {
         }
     }
 
-    public static List<byte[]> parseMessages(final String c) {
-        final String content = clearWhiteSpaceToUpper(c);
+    public static List<byte[]> parseMessages(final String stringMessage) {
+        final String content = clearWhiteSpaceToUpper(stringMessage);
         final int sixteen = 16;
         final int four = 4;
         // search for 16 FFs
@@ -73,8 +74,8 @@ public final class HexDumpBGPFileParser {
 
             // Assert that message is longer than minimum 19(header.length == 19)
             // If length in BGP 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);
+            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 byte[] message = BaseEncoding.base16().decode(hexMessage);
@@ -88,6 +89,6 @@ public final class HexDumpBGPFileParser {
 
     @VisibleForTesting
     static String clearWhiteSpaceToUpper(final String line) {
-        return line.replaceAll("\\s", "").toUpperCase();
+        return line.replaceAll("\\s", "").toUpperCase(Locale.ENGLISH);
     }
 }
index 3047c8f5866ceb2696ab5feb9d29ade882115f3f..97b872908034cfbe8a6a68fbff130294c81f22b8 100644 (file)
@@ -9,20 +9,33 @@ package org.opendaylight.protocol.bgp.util;
 
 import static org.hamcrest.core.Is.is;
 import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertThat;
 
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
 import java.util.List;
 import org.junit.Test;
 
 public class BGPBinaryFileParserTest {
 
-    private final byte ff = (byte) 255;
+    private static final byte FF = (byte) 255;
+
+    private static List<byte[]> extractFromFile(final String fileName) throws IOException {
+        final InputStream is = BGPBinaryFileParserTest.class.getResourceAsStream(fileName);
+        if (is == null) {
+            throw new IOException("Failed to get resource " + fileName);
+        }
+
+        final ByteArrayOutputStream bis = new ByteArrayOutputStream();
+        final byte[] data = new byte[1000];
+        int nread;
+        while ((nread = is.read(data, 0, data.length)) != -1) {
+            bis.write(data, 0, nread);
+        }
+        bis.flush();
+        return BinaryBGPDumpFileParser.parseMessages(bis.toByteArray());
+    }
 
     @Test
     public void testCorrectExtraction() throws IOException {
@@ -47,49 +60,18 @@ public class BGPBinaryFileParserTest {
 
     }
 
-    private static List<byte[]> extractFromFile(final String fileName) throws IOException {
-        final InputStream is = BGPBinaryFileParserTest.class.getResourceAsStream(fileName);
-        assertNotNull("File not found - " + fileName);
-        if (is == null) {
-            throw new IOException("Failed to get resource " + fileName);
-        }
-
-        final ByteArrayOutputStream bis = new ByteArrayOutputStream();
-        final byte[] data = new byte[1000];
-        int nRead = 0;
-        while ((nRead = is.read(data, 0, data.length)) != -1) {
-            bis.write(data, 0, nRead);
-        }
-        bis.flush();
-        return BinaryBGPDumpFileParser.parseMessages(bis.toByteArray());
-    }
-
     private void checkMarker(final List<byte[]> parsedMessages) {
         for (int i = 0; i < 16; i++) {
-            assertThat(parsedMessages.get(0)[i], is(this.ff));
+            assertThat(parsedMessages.get(0)[i], is(FF));
         }
     }
 
     /**
-     * In BgpMessages_wrong_header file, first FF sequence is corrupted
-     *
-     * @throws IOException
+     * In BgpMessages_wrong_header file, first FF sequence is corrupted.
      */
     @Test
     public void testCorruptedHeader() throws IOException {
         final List<byte[]> parsedMessages = extractFromFile("/BgpMessages_wrong_header.bin");
         assertEquals(42, parsedMessages.size());
     }
-
-    @Test(expected=UnsupportedOperationException.class)
-    public void testPrivateConstructor() throws Throwable {
-        final Constructor<BinaryBGPDumpFileParser> c = BinaryBGPDumpFileParser.class.getDeclaredConstructor();
-        c.setAccessible(true);
-        try {
-            c.newInstance();
-        } catch (InvocationTargetException e) {
-            throw e.getCause();
-        }
-    }
-
 }
index ca8d64891c306c2e95ef9890e929131622373e3f..1a27de1b86185009568985c53709a020713bfec7 100644 (file)
@@ -11,18 +11,17 @@ import static org.hamcrest.CoreMatchers.containsString;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertThat;
 import static org.junit.Assert.fail;
+
 import java.io.File;
 import java.io.FileNotFoundException;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
 import java.util.List;
 import org.junit.Test;
 
 public class BGPHexFileParserTest {
 
-    public static final String hexDumpFileName = "bgp_hex.txt";
-    private static final String fileNameInvalid = "BgpMessage_Hex_InvalidLength.bin";
-    private static final int expectedSize = 25;
+    private static final String HEX_DUMP_FILE_NAME = "bgp_hex.txt";
+    private static final String BGP_MESSAGE_HEX_INVALID_LENGTH_BIN = "BgpMessage_Hex_InvalidLength.bin";
+    private static final int EXPECTED_SIZE = 25;
 
     @Test
     public void testCleanWhiteSpace() {
@@ -32,18 +31,20 @@ public class BGPHexFileParserTest {
 
     @Test
     public void testParsing() throws Exception {
-        final List<byte[]> result = HexDumpBGPFileParser.parseMessages(getClass().getClassLoader().getResourceAsStream(
-            BGPHexFileParserTest.hexDumpFileName));
-        assertEquals(expectedSize, result.size());
+        final List<byte[]> result = HexDumpBGPFileParser.parseMessages(getClass().getClassLoader()
+                .getResourceAsStream(BGPHexFileParserTest.HEX_DUMP_FILE_NAME));
+        assertEquals(EXPECTED_SIZE, result.size());
     }
 
     @Test
     public void testParsingInvalidMessage() throws Exception {
         try {
-            HexDumpBGPFileParser.parseMessages(getClass().getClassLoader().getResourceAsStream(fileNameInvalid));
+            HexDumpBGPFileParser.parseMessages(getClass().getClassLoader()
+                    .getResourceAsStream(BGP_MESSAGE_HEX_INVALID_LENGTH_BIN));
             fail("Exception should have occured.");
         } catch (final IllegalArgumentException e) {
-            assertThat(e.getMessage(), containsString("Invalid message at index 0, length atribute is lower than 19"));
+            assertThat(e.getMessage(), containsString("Invalid message at index 0, "
+                    + "length atribute is lower than 19"));
         }
     }
 
@@ -56,16 +57,4 @@ public class BGPHexFileParserTest {
             assertThat(e.getMessage(), containsString("bad file name"));
         }
     }
-
-    @Test(expected=UnsupportedOperationException.class)
-    public void testPrivateConstructor() throws Throwable {
-        final Constructor<HexDumpBGPFileParser> c = HexDumpBGPFileParser.class.getDeclaredConstructor();
-        c.setAccessible(true);
-        try {
-            c.newInstance();
-        } catch (InvocationTargetException e) {
-            throw e.getCause();
-        }
-    }
-
 }