Enforce checkstyle and findbug under PCE Api 85/66385/8
authorClaudio D. Gasparini <claudio.gasparini@pantheon.tech>
Tue, 12 Dec 2017 11:33:04 +0000 (12:33 +0100)
committerClaudio D. Gasparini <claudio.gasparini@pantheon.tech>
Wed, 20 Dec 2017 09:43:25 +0000 (10:43 +0100)
Change-Id: Ifdda7b466bb43d2f3e2d7ade338129fc6bd30bae
Signed-off-by: Claudio D. Gasparini <claudio.gasparini@pantheon.tech>
17 files changed:
pcep/api/pom.xml
pcep/api/src/main/java/org/opendaylight/protocol/pcep/PCEPCapability.java
pcep/api/src/main/java/org/opendaylight/protocol/pcep/PCEPPeerProposal.java
pcep/api/src/main/java/org/opendaylight/protocol/pcep/PCEPSession.java
pcep/api/src/main/java/org/opendaylight/protocol/pcep/PCEPSessionListener.java
pcep/api/src/main/java/org/opendaylight/protocol/pcep/PCEPSessionListenerFactory.java
pcep/api/src/main/java/org/opendaylight/protocol/pcep/PCEPSessionNegotiatorFactory.java
pcep/api/src/main/java/org/opendaylight/protocol/pcep/PCEPSessionNegotiatorFactoryDependencies.java
pcep/api/src/main/java/org/opendaylight/protocol/pcep/PCEPSessionProposalFactory.java
pcep/api/src/main/java/org/opendaylight/protocol/pcep/TerminationReason.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/PCEPSessionImpl.java
pcep/impl/src/test/java/org/opendaylight/protocol/pcep/impl/SimpleSessionListener.java
pcep/pcc-mock/src/main/java/org/opendaylight/protocol/pcep/pcc/mock/protocol/PCCSessionListener.java
pcep/pcc-mock/src/test/java/org/opendaylight/protocol/pcep/pcc/mock/TestingSessionListener.java
pcep/testtool/src/main/java/org/opendaylight/protocol/pcep/testtool/TestingSessionListener.java
pcep/testtool/src/test/java/org/opendaylight/protocol/pcep/testtool/SimpleSessionListener.java
pcep/topology/topology-provider/src/main/java/org/opendaylight/bgpcep/pcep/topology/provider/AbstractTopologySessionListener.java

index 33c680e9f7bf677948757baf552c160099940ed0..988ec939fafb7ee83d52bfb6438187af11c07446 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 ed5fc07547737f18849374fb4324884aaddff428..cc89bb4c7944a623fbd4bfcaa880503e694f3325 100644 (file)
@@ -11,17 +11,22 @@ import java.net.InetSocketAddress;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.open.TlvsBuilder;
 
 /**
- * Stores usability for available capabilities
+ * Stores usability for available capabilities.
  */
 public interface PCEPCapability {
 
     /**
-     * Sets stateful capabilities tlv in incoming builder
+     * Sets stateful capabilities tlv in incoming builder.
      *
-     * @param address
+     * @param address peer address to assign capability proposal
      * @param builder for TLVs included in PCEPOpenObject
      */
     void setCapabilityProposal(InetSocketAddress address, TlvsBuilder builder);
 
+    /**
+     * Returs stateful capability state.
+     *
+     * @return true if capability is present
+     */
     boolean isStateful();
 }
index 2c60e068bb63fc3891b62cedd93aca6e2a540454..73c7217f361274d14762277598e3674350f57e37 100644 (file)
@@ -12,15 +12,14 @@ import javax.annotation.Nonnull;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.open.TlvsBuilder;
 
 /**
- * Proposal from peer for establishment of PCEP session
+ * Proposal from peer for establishment of PCEP session.
  */
 public interface PCEPPeerProposal {
-
     /**
-     * Sets specific TLVs into incoming builder
+     * Sets specific TLVs into incoming builder.
      *
-     * @param address of the pcep speaker to be assigned given tlvs
-     * @param tlvs    builder, to attach tl's with more information to be sent under Open message
+     * @param address     pcep speaker address
+     * @param openBuilder to assign specific proposal
      */
-    void setPeerSpecificProposal(@Nonnull InetSocketAddress address, @Nonnull TlvsBuilder tlvs);
+    void setPeerSpecificProposal(@Nonnull InetSocketAddress address, @Nonnull TlvsBuilder openBuilder);
 }
index 5288f90392e4ebae23518561525fd7f40dd07bbb..6b9bc274b6efa4251a63aca7318fa25151125ce8 100644 (file)
@@ -9,6 +9,7 @@ package org.opendaylight.protocol.pcep;
 
 import io.netty.util.concurrent.Future;
 import java.net.InetAddress;
+import javax.annotation.Nonnull;
 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.open.object.open.Tlvs;
 
@@ -32,14 +33,35 @@ public interface PCEPSession extends PCEPSessionState, AutoCloseable {
 
     void close(TerminationReason reason);
 
+    /**
+     * Returns session characteristics of the remote PCEP Speaker.
+     *
+     * @return Open message TLVs
+     */
     Tlvs getRemoteTlvs();
 
+    /**
+     * Returns remote address.
+     *
+     * @return inet address
+     */
+    @Nonnull
     InetAddress getRemoteAddress();
 
     /**
-     * Returns session characteristics of the local PCEP Speaker
+     * Returns session characteristics of the local PCEP Speaker.
+     *
+     * @return Open message TLVs
+     */
+    Tlvs getLocalTlvs();
+
+    /**
+     * Returns session characteristics of the local PCEP Speaker.
      *
      * @return Open message TLVs
      */
-    Tlvs localSessionCharacteristics();
+    @Deprecated
+    default Tlvs localSessionCharacteristics() {
+        return getLocalTlvs();
+    }
 }
index 8bca10edd35f170a767c19360b7993f2d3f54219..1e103396db55030bd4f5df52a47d43365498c2e5 100644 (file)
@@ -8,6 +8,7 @@
 package org.opendaylight.protocol.pcep;
 
 import java.util.EventListener;
+import javax.annotation.Nonnull;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
 
 /**
@@ -19,16 +20,16 @@ public interface PCEPSessionListener extends EventListener {
      *
      * @param session Peer address families which we accepted
      */
-    void onSessionUp(PCEPSession session);
+    void onSessionUp(@Nonnull PCEPSession session);
 
     /**
      * Fired when the session went down because of an IO error. Implementation should take care of closing underlying
      * session.
      *
-     * @param session that went down
-     * @param e Exception that was thrown as the cause of session being down
+     * @param session   that went down
+     * @param exception Exception that was thrown as the cause of session being down
      */
-    void onSessionDown(PCEPSession session, Exception e);
+    void onSessionDown(@Nonnull PCEPSession session, @Nonnull Exception exception);
 
     /**
      * Fired when the session is terminated locally. The session has already been closed and transitioned to IDLE state.
@@ -36,12 +37,12 @@ public interface PCEPSessionListener extends EventListener {
      *
      * @param reason the cause why the session went down
      */
-    void onSessionTerminated(PCEPSession session, PCEPTerminationReason reason);
+    void onSessionTerminated(@Nonnull PCEPSession session, @Nonnull PCEPTerminationReason reason);
 
     /**
      * Fired when a normal protocol message is received.
      *
      * @param message Protocol message
      */
-    void onMessage(PCEPSession session, Message message);
+    void onMessage(@Nonnull PCEPSession session, @Nonnull Message message);
 }
index 9b36106466d2d347305c9baf72b9d60696745826..8da51084f4442a8be8400ab1097e6ed8d14deef0 100644 (file)
@@ -7,14 +7,17 @@
  */
 package org.opendaylight.protocol.pcep;
 
+import javax.annotation.Nonnull;
+
 /**
  * Factory for generating PCEP Session Listeners. Used by a server.
  */
 public interface PCEPSessionListenerFactory {
     /**
-     * Returns one session listener
+     * Returns one session listener.
      *
      * @return specific session listener
      */
+    @Nonnull
     PCEPSessionListener getSessionListener();
 }
index 52c2a1e4ac371ee6baa23673d34b1fb290e8bd68..c89be4f31353f56b076d25569fe2840778c79825 100644 (file)
@@ -14,7 +14,7 @@ import javax.annotation.Nonnull;
 /**
  * Factory for creating PCEP session negotiator.
  *
- * @param <S>
+ * @param <S> PCEPSession implementation
  */
 public interface PCEPSessionNegotiatorFactory<S extends PCEPSession> {
 
@@ -33,7 +33,7 @@ public interface PCEPSessionNegotiatorFactory<S extends PCEPSession> {
             @Nonnull Promise<S> promise);
 
     /**
-     * Returns a PCEPSessionProposalFactory
+     * Returns a PCEPSessionProposalFactory.
      *
      * @return session factory
      */
index dd3ed605ebcd7ecb5ca31ea493839a51944a7a05..6da96c80f7ba94b6512c5250f05c0677193ab0c4 100644 (file)
@@ -12,7 +12,7 @@ import javax.annotation.Nonnull;
 import javax.annotation.Nullable;
 
 /**
- * Contains required dependencies for create SessionNegotiator
+ * Contains required dependencies for create SessionNegotiator.
  */
 public interface PCEPSessionNegotiatorFactoryDependencies {
     /**
@@ -24,9 +24,9 @@ public interface PCEPSessionNegotiatorFactoryDependencies {
     PCEPSessionListenerFactory getListenerFactory();
 
     /**
-     * Returns a non mandatory PeerProposal information used in our Open message.
+     * PeerProposal information used in our Open message.
      *
-     * @return by default null or peerProposal if implemented.
+     * @return peerProposal null by default since its not mandatory. Otherwise method should be override it.
      */
     @Nullable
     default PCEPPeerProposal getPeerProposal() {
index ab6c2a89de5584500e990998acf548f302fa4692..0089376ae996eb2dc169b6f6c0dc5ad00dbd546b 100644 (file)
@@ -18,6 +18,8 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.typ
  */
 public interface PCEPSessionProposalFactory {
     /**
+     * Creates Open with session proposal.
+     *
      * @param address      serves as constraint, so that factory is able to return different proposals for different
      *                     addresses
      * @param sessionId    is used for creation of PCEPOpenObject
@@ -28,7 +30,7 @@ public interface PCEPSessionProposalFactory {
     Open getSessionProposal(@Nonnull InetSocketAddress address, int sessionId, @Nullable PCEPPeerProposal peerProposal);
 
     /**
-     * Returns list containing PCEP Capabilities
+     * Returns list containing PCEP Capabilities.
      *
      * @return PCEPCapabilities
      */
index 84815407eb37c2a9c8252a4035a8fe05ab579b71..329ff67f09412f7054460f5d1b4f30f53f010474 100644 (file)
@@ -11,9 +11,12 @@ import com.google.common.collect.Maps;
 import java.util.Map;
 
 public enum TerminationReason {
-    UNKNOWN((short) 1), EXP_DEADTIMER((short) 2), MALFORMED_MSG((short) 3), TOO_MANY_UNKNWN_REQS((short) 4), TOO_MANY_UNKNOWN_MSGS((short) 5);
+    UNKNOWN((short) 1),
+    EXP_DEADTIMER((short) 2),
+    MALFORMED_MSG((short) 3),
+    TOO_MANY_UNKNWN_REQS((short) 4),
+    TOO_MANY_UNKNOWN_MSGS((short) 5);
 
-    private short value;
     private static final Map<Short, TerminationReason> VALUE_MAP;
 
     static {
@@ -23,26 +26,28 @@ public enum TerminationReason {
         }
     }
 
+    private short value;
+
     TerminationReason(final short value) {
         this.value = value;
     }
 
     /**
-     * Gets value of termination reason.
+     * Gets termination reason for specific short value.
      *
-     * @return short value
+     * @param valueArg corresponding to Termination reason
+     * @return corresponding TerminationReason item
      */
-    public short getShortValue() {
-        return this.value;
+    public static TerminationReason forValue(final short valueArg) {
+        return VALUE_MAP.get(valueArg);
     }
 
     /**
-     * Gets termination reason for specific short value.
+     * Gets value of termination reason.
      *
-     * @param valueArg
-     * @return corresponding TerminationReason item
+     * @return short value
      */
-    public static TerminationReason forValue(final short valueArg) {
-        return VALUE_MAP.get(valueArg);
+    public short getShortValue() {
+        return this.value;
     }
 }
index 1a415e0f2e96d686d44f9ff183c55e28b286f741..d16794d6b69fe7cd431ddbb7a418dbc438dc7edb 100644 (file)
@@ -431,7 +431,7 @@ public class PCEPSessionImpl extends SimpleChannelInboundHandler<Message> implem
     }
 
     @Override
-    public Tlvs localSessionCharacteristics() {
+    public Tlvs getLocalTlvs() {
         return this.localOpen.getTlvs();
     }
 
index 4c3ba69252dba5f65107b8682231fd56d69e1740..ad3bdd66c045b5916f3b65a8aa36e3193bb3eab7 100644 (file)
@@ -46,8 +46,8 @@ public class SimpleSessionListener implements PCEPSessionListener {
     }
 
     @Override
-    public void onSessionDown(final PCEPSession session, final Exception e) {
-        LOG.debug("Session down.", e);
+    public void onSessionDown(final PCEPSession session, final Exception exception) {
+        LOG.debug("Session down.", exception);
         this.up = false;
         // this.notifyAll();
     }
index d6748697946db5cac6b9cc754fb4f4a4500b8ca0..1fa4ccf2b8b170bb0535c2e9ab7c72f876bf4a33 100644 (file)
@@ -66,8 +66,8 @@ public final class PCCSessionListener implements PCEPSessionListener, PCCSession
     }
 
     @Override
-    public void onSessionDown(final PCEPSession session, final Exception e) {
-        LOG.info("Session down with cause : {} or exception: {}", e.getCause(), e, e);
+    public void onSessionDown(final PCEPSession session, final Exception exception) {
+        LOG.info("Session down with cause : {} or exception: {}", exception.getCause(), exception, exception);
         this.tunnelManager.onSessionDown(this);
         try {
             session.close();
index 5429c1a4c11161755d4b125d4344616d08e5b094..ca7b92bd276ebbbca388df45352adbbcf7fa18e4 100644 (file)
@@ -51,8 +51,8 @@ public class TestingSessionListener implements PCEPSessionListener, ListenerChec
     }
 
     @Override
-    public void onSessionDown(final PCEPSession session, final Exception e) {
-        LOG.debug("Session down. Cause : {} ", e, e);
+    public void onSessionDown(final PCEPSession session, final Exception exception) {
+        LOG.debug("Session down. Cause : {} ", exception, exception);
         this.up = false;
         this.session = null;
     }
index 0599d6ad94bdff7ee210c703c90cbc26a7e3b8d8..261a0e1dac0f464119578a70cc1b7c2a4a04c804 100644 (file)
@@ -40,8 +40,8 @@ public class TestingSessionListener implements PCEPSessionListener {
     }
 
     @Override
-    public void onSessionDown(final PCEPSession session, final Exception e) {
-        LOG.debug("Session down. Cause : {} ", e, e);
+    public void onSessionDown(final PCEPSession session, final Exception exception) {
+        LOG.debug("Session down. Cause : {} ", exception, exception);
         this.up = false;
     }
 
index e4630171126982023b6aa8dff6ed15f12a0ca02e..ebe30c77ec77f2e502f2cf38e7c5e5a406afabbe 100644 (file)
@@ -40,8 +40,8 @@ public class SimpleSessionListener implements PCEPSessionListener {
     }
 
     @Override
-    public void onSessionDown(final PCEPSession session, final Exception e) {
-        LOG.debug("Session down with cause : {} or exception: {}", e.getCause(), e, e);
+    public void onSessionDown(final PCEPSession session, final Exception exception) {
+        LOG.debug("Session down with cause : {} or exception: {}", exception.getCause(), exception, exception);
         try {
             session.close();
         } catch (Exception ie) {
index 22aa35ccc307c9aca705d82e55ed9006d5cfeecc..ec6f2489aee7c5a2683a89d92c0ebc755c1ca8bb 100755 (executable)
@@ -278,8 +278,8 @@ public abstract class AbstractTopologySessionListener<S, L> implements TopologyS
     }
 
     @Override
-    public final synchronized void onSessionDown(final PCEPSession session, final Exception e) {
-        LOG.warn("Session {} went down unexpectedly", session, e);
+    public final synchronized void onSessionDown(final PCEPSession session, final Exception exception) {
+        LOG.warn("Session {} went down unexpectedly", session, exception);
         tearDown(session);
     }