From: Claudio D. Gasparini Date: Tue, 12 Dec 2017 11:33:04 +0000 (+0100) Subject: Enforce checkstyle and findbug under PCE Api X-Git-Tag: release/oxygen~74 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=commitdiff_plain;h=de5344d307234e5813e476d956eefd9af5ac9b11;p=bgpcep.git Enforce checkstyle and findbug under PCE Api Change-Id: Ifdda7b466bb43d2f3e2d7ade338129fc6bd30bae Signed-off-by: Claudio D. Gasparini --- diff --git a/pcep/api/pom.xml b/pcep/api/pom.xml index 33c680e9f7..988ec939fa 100644 --- a/pcep/api/pom.xml +++ b/pcep/api/pom.xml @@ -89,6 +89,25 @@ + + + + org.apache.maven.plugins + maven-checkstyle-plugin + + checkstyle.violationSeverity=error + + + + org.codehaus.mojo + findbugs-maven-plugin + + true + + + + + scm:git:ssh://git.opendaylight.org:29418/bgpcep.git scm:git:ssh://git.opendaylight.org:29418/bgpcep.git diff --git a/pcep/api/src/main/java/org/opendaylight/protocol/pcep/PCEPCapability.java b/pcep/api/src/main/java/org/opendaylight/protocol/pcep/PCEPCapability.java index ed5fc07547..cc89bb4c79 100644 --- a/pcep/api/src/main/java/org/opendaylight/protocol/pcep/PCEPCapability.java +++ b/pcep/api/src/main/java/org/opendaylight/protocol/pcep/PCEPCapability.java @@ -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(); } diff --git a/pcep/api/src/main/java/org/opendaylight/protocol/pcep/PCEPPeerProposal.java b/pcep/api/src/main/java/org/opendaylight/protocol/pcep/PCEPPeerProposal.java index 2c60e068bb..73c7217f36 100644 --- a/pcep/api/src/main/java/org/opendaylight/protocol/pcep/PCEPPeerProposal.java +++ b/pcep/api/src/main/java/org/opendaylight/protocol/pcep/PCEPPeerProposal.java @@ -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); } diff --git a/pcep/api/src/main/java/org/opendaylight/protocol/pcep/PCEPSession.java b/pcep/api/src/main/java/org/opendaylight/protocol/pcep/PCEPSession.java index 5288f90392..6b9bc274b6 100644 --- a/pcep/api/src/main/java/org/opendaylight/protocol/pcep/PCEPSession.java +++ b/pcep/api/src/main/java/org/opendaylight/protocol/pcep/PCEPSession.java @@ -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(); + } } diff --git a/pcep/api/src/main/java/org/opendaylight/protocol/pcep/PCEPSessionListener.java b/pcep/api/src/main/java/org/opendaylight/protocol/pcep/PCEPSessionListener.java index 8bca10edd3..1e103396db 100644 --- a/pcep/api/src/main/java/org/opendaylight/protocol/pcep/PCEPSessionListener.java +++ b/pcep/api/src/main/java/org/opendaylight/protocol/pcep/PCEPSessionListener.java @@ -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); } diff --git a/pcep/api/src/main/java/org/opendaylight/protocol/pcep/PCEPSessionListenerFactory.java b/pcep/api/src/main/java/org/opendaylight/protocol/pcep/PCEPSessionListenerFactory.java index 9b36106466..8da51084f4 100644 --- a/pcep/api/src/main/java/org/opendaylight/protocol/pcep/PCEPSessionListenerFactory.java +++ b/pcep/api/src/main/java/org/opendaylight/protocol/pcep/PCEPSessionListenerFactory.java @@ -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(); } diff --git a/pcep/api/src/main/java/org/opendaylight/protocol/pcep/PCEPSessionNegotiatorFactory.java b/pcep/api/src/main/java/org/opendaylight/protocol/pcep/PCEPSessionNegotiatorFactory.java index 52c2a1e4ac..c89be4f313 100644 --- a/pcep/api/src/main/java/org/opendaylight/protocol/pcep/PCEPSessionNegotiatorFactory.java +++ b/pcep/api/src/main/java/org/opendaylight/protocol/pcep/PCEPSessionNegotiatorFactory.java @@ -14,7 +14,7 @@ import javax.annotation.Nonnull; /** * Factory for creating PCEP session negotiator. * - * @param + * @param PCEPSession implementation */ public interface PCEPSessionNegotiatorFactory { @@ -33,7 +33,7 @@ public interface PCEPSessionNegotiatorFactory { @Nonnull Promise promise); /** - * Returns a PCEPSessionProposalFactory + * Returns a PCEPSessionProposalFactory. * * @return session factory */ diff --git a/pcep/api/src/main/java/org/opendaylight/protocol/pcep/PCEPSessionNegotiatorFactoryDependencies.java b/pcep/api/src/main/java/org/opendaylight/protocol/pcep/PCEPSessionNegotiatorFactoryDependencies.java index dd3ed605eb..6da96c80f7 100644 --- a/pcep/api/src/main/java/org/opendaylight/protocol/pcep/PCEPSessionNegotiatorFactoryDependencies.java +++ b/pcep/api/src/main/java/org/opendaylight/protocol/pcep/PCEPSessionNegotiatorFactoryDependencies.java @@ -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() { diff --git a/pcep/api/src/main/java/org/opendaylight/protocol/pcep/PCEPSessionProposalFactory.java b/pcep/api/src/main/java/org/opendaylight/protocol/pcep/PCEPSessionProposalFactory.java index ab6c2a89de..0089376ae9 100644 --- a/pcep/api/src/main/java/org/opendaylight/protocol/pcep/PCEPSessionProposalFactory.java +++ b/pcep/api/src/main/java/org/opendaylight/protocol/pcep/PCEPSessionProposalFactory.java @@ -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 */ diff --git a/pcep/api/src/main/java/org/opendaylight/protocol/pcep/TerminationReason.java b/pcep/api/src/main/java/org/opendaylight/protocol/pcep/TerminationReason.java index 84815407eb..329ff67f09 100644 --- a/pcep/api/src/main/java/org/opendaylight/protocol/pcep/TerminationReason.java +++ b/pcep/api/src/main/java/org/opendaylight/protocol/pcep/TerminationReason.java @@ -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 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; } } diff --git a/pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/PCEPSessionImpl.java b/pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/PCEPSessionImpl.java index 1a415e0f2e..d16794d6b6 100644 --- a/pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/PCEPSessionImpl.java +++ b/pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/PCEPSessionImpl.java @@ -431,7 +431,7 @@ public class PCEPSessionImpl extends SimpleChannelInboundHandler implem } @Override - public Tlvs localSessionCharacteristics() { + public Tlvs getLocalTlvs() { return this.localOpen.getTlvs(); } diff --git a/pcep/impl/src/test/java/org/opendaylight/protocol/pcep/impl/SimpleSessionListener.java b/pcep/impl/src/test/java/org/opendaylight/protocol/pcep/impl/SimpleSessionListener.java index 4c3ba69252..ad3bdd66c0 100644 --- a/pcep/impl/src/test/java/org/opendaylight/protocol/pcep/impl/SimpleSessionListener.java +++ b/pcep/impl/src/test/java/org/opendaylight/protocol/pcep/impl/SimpleSessionListener.java @@ -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(); } diff --git a/pcep/pcc-mock/src/main/java/org/opendaylight/protocol/pcep/pcc/mock/protocol/PCCSessionListener.java b/pcep/pcc-mock/src/main/java/org/opendaylight/protocol/pcep/pcc/mock/protocol/PCCSessionListener.java index d674869794..1fa4ccf2b8 100644 --- a/pcep/pcc-mock/src/main/java/org/opendaylight/protocol/pcep/pcc/mock/protocol/PCCSessionListener.java +++ b/pcep/pcc-mock/src/main/java/org/opendaylight/protocol/pcep/pcc/mock/protocol/PCCSessionListener.java @@ -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(); diff --git a/pcep/pcc-mock/src/test/java/org/opendaylight/protocol/pcep/pcc/mock/TestingSessionListener.java b/pcep/pcc-mock/src/test/java/org/opendaylight/protocol/pcep/pcc/mock/TestingSessionListener.java index 5429c1a4c1..ca7b92bd27 100644 --- a/pcep/pcc-mock/src/test/java/org/opendaylight/protocol/pcep/pcc/mock/TestingSessionListener.java +++ b/pcep/pcc-mock/src/test/java/org/opendaylight/protocol/pcep/pcc/mock/TestingSessionListener.java @@ -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; } diff --git a/pcep/testtool/src/main/java/org/opendaylight/protocol/pcep/testtool/TestingSessionListener.java b/pcep/testtool/src/main/java/org/opendaylight/protocol/pcep/testtool/TestingSessionListener.java index 0599d6ad94..261a0e1dac 100644 --- a/pcep/testtool/src/main/java/org/opendaylight/protocol/pcep/testtool/TestingSessionListener.java +++ b/pcep/testtool/src/main/java/org/opendaylight/protocol/pcep/testtool/TestingSessionListener.java @@ -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; } diff --git a/pcep/testtool/src/test/java/org/opendaylight/protocol/pcep/testtool/SimpleSessionListener.java b/pcep/testtool/src/test/java/org/opendaylight/protocol/pcep/testtool/SimpleSessionListener.java index e463017112..ebe30c77ec 100644 --- a/pcep/testtool/src/test/java/org/opendaylight/protocol/pcep/testtool/SimpleSessionListener.java +++ b/pcep/testtool/src/test/java/org/opendaylight/protocol/pcep/testtool/SimpleSessionListener.java @@ -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) { diff --git a/pcep/topology/topology-provider/src/main/java/org/opendaylight/bgpcep/pcep/topology/provider/AbstractTopologySessionListener.java b/pcep/topology/topology-provider/src/main/java/org/opendaylight/bgpcep/pcep/topology/provider/AbstractTopologySessionListener.java index 22aa35ccc3..ec6f2489ae 100755 --- a/pcep/topology/topology-provider/src/main/java/org/opendaylight/bgpcep/pcep/topology/provider/AbstractTopologySessionListener.java +++ b/pcep/topology/topology-provider/src/main/java/org/opendaylight/bgpcep/pcep/topology/provider/AbstractTopologySessionListener.java @@ -278,8 +278,8 @@ public abstract class AbstractTopologySessionListener 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); }