From 634dfac8eead60f443bf75e749c70d1f2bb29198 Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Tue, 21 Aug 2018 01:07:54 +0200 Subject: [PATCH] Fix findbugs warnings Upgraded findbugs finds these, fix them up. Change-Id: Id5a008cddc6616c3a93f0528efca00b86843fc3c Signed-off-by: Robert Varga --- ...ractDependentComponentFactoryMetadata.java | 2 + .../ext/OpendaylightNamespaceHandler.java | 2 +- .../ext/StaticServiceReferenceRecipe.java | 2 +- .../client/AbstractClientConnection.java | 2 +- .../access/client/ClientActorBehavior.java | 2 +- .../access/client/ReconnectForwarder.java | 3 - .../md/sal/trace/dom/impl/TracingBroker.java | 3 +- .../app/impl/EventSourceTopology.java | 4 +- .../controller/cluster/raft/RaftActor.java | 2 +- .../cluster/raft/RaftActorContextImpl.java | 2 +- .../raft/RaftActorRecoverySupport.java | 28 +++--- .../behaviors/AbstractRaftActorBehavior.java | 28 +++--- .../raft/behaviors/SyncStatusTracker.java | 2 +- ...iumNotificationProviderServiceAdapter.java | 13 +-- ...nProviderServiceWithInterestListeners.java | 6 +- .../BindingDOMMountPointListenerAdapter.java | 9 +- .../BindingDOMMountPointServiceAdapter.java | 16 ++-- .../admin/ClusterAdminRpcService.java | 6 +- .../common/actor/AbstractUntypedActor.java | 2 + .../actor/AbstractUntypedPersistentActor.java | 2 + .../akka/impl/ActorSystemProviderImpl.java | 3 +- .../dds/ModuleShardBackendResolver.java | 2 +- .../dds/SimpleShardBackendResolver.java | 2 +- .../actors/dds/SingleClientHistory.java | 2 +- ...taTreeNotificationPublisherActorProxy.java | 8 +- .../datastore/CompositeDataTreeCohort.java | 8 +- .../DataTreeChangeListenerProxy.java | 2 +- .../DataTreeCohortRegistrationProxy.java | 14 ++- .../DebugThreePhaseCommitCohort.java | 3 + .../FrontendClientMetadataBuilder.java | 2 +- .../LocalThreePhaseCommitCohort.java | 9 +- .../datastore/NoOpTransactionContext.java | 4 +- .../datastore/RemoteTransactionContext.java | 4 +- .../datastore/ShardCommitCoordinator.java | 8 +- .../cluster/datastore/ShardDataTree.java | 8 +- .../datastore/ShardRecoveryCoordinator.java | 2 +- .../datastore/ShardSnapshotCohort.java | 2 +- .../ThreePhaseCommitCohortProxy.java | 2 +- .../datastore/TransactionContextCleanup.java | 2 +- .../entityownership/EntityOwnershipShard.java | 2 +- .../datastore/shardmanager/ShardManager.java | 95 ++++++++++--------- .../ShardManagerGetSnapshotReplyActor.java | 13 +-- .../cluster/datastore/utils/ActorContext.java | 62 ++++++------ .../broker/impl/SerializedDOMDataBroker.java | 2 +- .../controller/remote/rpc/RpcInvoker.java | 2 +- .../rpc/registry/gossip/BucketStoreActor.java | 2 +- .../mbeans/RemoteRpcRegistryMXBeanImpl.java | 6 +- .../it/listener/PeopleCarListener.java | 2 +- .../clustering/it/provider/CarProvider.java | 2 + .../it/provider/PeopleProvider.java | 2 +- .../it/provider/impl/IdIntsListener.java | 2 +- .../kitchen/impl/KitchenServiceImpl.java | 7 +- .../toaster/provider/OpendaylightToaster.java | 4 +- 53 files changed, 224 insertions(+), 202 deletions(-) diff --git a/opendaylight/blueprint/src/main/java/org/opendaylight/controller/blueprint/ext/AbstractDependentComponentFactoryMetadata.java b/opendaylight/blueprint/src/main/java/org/opendaylight/controller/blueprint/ext/AbstractDependentComponentFactoryMetadata.java index e823523e8e..37343b9362 100644 --- a/opendaylight/blueprint/src/main/java/org/opendaylight/controller/blueprint/ext/AbstractDependentComponentFactoryMetadata.java +++ b/opendaylight/blueprint/src/main/java/org/opendaylight/controller/blueprint/ext/AbstractDependentComponentFactoryMetadata.java @@ -8,6 +8,7 @@ package org.opendaylight.controller.blueprint.ext; import com.google.common.base.Preconditions; +import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -32,6 +33,7 @@ import org.slf4j.LoggerFactory; * @author Thomas Pantelis */ abstract class AbstractDependentComponentFactoryMetadata implements DependentComponentFactoryMetadata { + @SuppressFBWarnings("SLF4J_LOGGER_SHOULD_BE_PRIVATE") final Logger log = LoggerFactory.getLogger(getClass()); private final String id; private final AtomicBoolean started = new AtomicBoolean(); diff --git a/opendaylight/blueprint/src/main/java/org/opendaylight/controller/blueprint/ext/OpendaylightNamespaceHandler.java b/opendaylight/blueprint/src/main/java/org/opendaylight/controller/blueprint/ext/OpendaylightNamespaceHandler.java index 01f922cc61..ff22f1bc30 100644 --- a/opendaylight/blueprint/src/main/java/org/opendaylight/controller/blueprint/ext/OpendaylightNamespaceHandler.java +++ b/opendaylight/blueprint/src/main/java/org/opendaylight/controller/blueprint/ext/OpendaylightNamespaceHandler.java @@ -208,7 +208,7 @@ public final class OpendaylightNamespaceHandler implements NamespaceHandler { + " can only be used on the root element"); } - LOG.debug("{}: {}", propertyName, attr.getValue()); + LOG.debug("Property {} = {}", propertyName, attr.getValue()); if (!Boolean.parseBoolean(attr.getValue())) { return component; diff --git a/opendaylight/blueprint/src/main/java/org/opendaylight/controller/blueprint/ext/StaticServiceReferenceRecipe.java b/opendaylight/blueprint/src/main/java/org/opendaylight/controller/blueprint/ext/StaticServiceReferenceRecipe.java index a3c6896fbf..fdeea3bb09 100644 --- a/opendaylight/blueprint/src/main/java/org/opendaylight/controller/blueprint/ext/StaticServiceReferenceRecipe.java +++ b/opendaylight/blueprint/src/main/java/org/opendaylight/controller/blueprint/ext/StaticServiceReferenceRecipe.java @@ -58,7 +58,7 @@ class StaticServiceReferenceRecipe extends AbstractServiceReferenceRecipe { LOG.debug("{}: In untrack {}", getName(), reference); if (trackedServiceReference == reference) { - LOG.debug("{}: Current reference has been untracked", getName(), trackedServiceReference); + LOG.debug("{}: Current reference {} has been untracked", getName(), trackedServiceReference); } } diff --git a/opendaylight/md-sal/cds-access-client/src/main/java/org/opendaylight/controller/cluster/access/client/AbstractClientConnection.java b/opendaylight/md-sal/cds-access-client/src/main/java/org/opendaylight/controller/cluster/access/client/AbstractClientConnection.java index c9be5be548..af66369271 100644 --- a/opendaylight/md-sal/cds-access-client/src/main/java/org/opendaylight/controller/cluster/access/client/AbstractClientConnection.java +++ b/opendaylight/md-sal/cds-access-client/src/main/java/org/opendaylight/controller/cluster/access/client/AbstractClientConnection.java @@ -262,7 +262,7 @@ public abstract class AbstractClientConnection { TimeUnit.NANOSECONDS.sleep(delay); } catch (InterruptedException e) { Thread.currentThread().interrupt(); - LOG.debug("Interrupted after sleeping {}ns", e, currentTime() - now); + LOG.debug("Interrupted after sleeping {}ns", currentTime() - now, e); } } diff --git a/opendaylight/md-sal/cds-access-client/src/main/java/org/opendaylight/controller/cluster/access/client/ClientActorBehavior.java b/opendaylight/md-sal/cds-access-client/src/main/java/org/opendaylight/controller/cluster/access/client/ClientActorBehavior.java index 3f6515cbb8..fa2e3b76d8 100644 --- a/opendaylight/md-sal/cds-access-client/src/main/java/org/opendaylight/controller/cluster/access/client/ClientActorBehavior.java +++ b/opendaylight/md-sal/cds-access-client/src/main/java/org/opendaylight/controller/cluster/access/client/ClientActorBehavior.java @@ -418,7 +418,7 @@ public abstract class ClientActorBehavior extends try { return cookie.equals(extractCookie(id)); } catch (IllegalArgumentException e) { - LOG.debug("extractCookie failed while cancelling slicing for cookie {}: {}", cookie, e); + LOG.debug("extractCookie failed while cancelling slicing for cookie {}", cookie, e); return false; } }); diff --git a/opendaylight/md-sal/cds-access-client/src/main/java/org/opendaylight/controller/cluster/access/client/ReconnectForwarder.java b/opendaylight/md-sal/cds-access-client/src/main/java/org/opendaylight/controller/cluster/access/client/ReconnectForwarder.java index 58c9e7549e..58334f91d7 100644 --- a/opendaylight/md-sal/cds-access-client/src/main/java/org/opendaylight/controller/cluster/access/client/ReconnectForwarder.java +++ b/opendaylight/md-sal/cds-access-client/src/main/java/org/opendaylight/controller/cluster/access/client/ReconnectForwarder.java @@ -8,8 +8,6 @@ package org.opendaylight.controller.cluster.access.client; import com.google.common.base.Preconditions; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; /** * Forwarder class responsible for routing requests from the previous connection incarnation back to the originator, @@ -18,7 +16,6 @@ import org.slf4j.LoggerFactory; * @author Robert Varga */ public abstract class ReconnectForwarder { - static final Logger LOG = LoggerFactory.getLogger(ReconnectForwarder.class); // Visible for subclass method handle private final AbstractReceivingClientConnection successor; diff --git a/opendaylight/md-sal/mdsal-trace/dom-impl/src/main/java/org/opendaylight/controller/md/sal/trace/dom/impl/TracingBroker.java b/opendaylight/md-sal/mdsal-trace/dom-impl/src/main/java/org/opendaylight/controller/md/sal/trace/dom/impl/TracingBroker.java index cdb4c71693..7103a00768 100644 --- a/opendaylight/md-sal/mdsal-trace/dom-impl/src/main/java/org/opendaylight/controller/md/sal/trace/dom/impl/TracingBroker.java +++ b/opendaylight/md-sal/mdsal-trace/dom-impl/src/main/java/org/opendaylight/controller/md/sal/trace/dom/impl/TracingBroker.java @@ -9,6 +9,7 @@ package org.opendaylight.controller.md.sal.trace.dom.impl; import static java.util.Objects.requireNonNull; +import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import java.io.PrintStream; import java.util.ArrayList; import java.util.HashMap; @@ -100,7 +101,7 @@ import org.slf4j.LoggerFactory; * */ public class TracingBroker implements TracingDOMDataBroker { - + @SuppressFBWarnings("SLF4J_LOGGER_SHOULD_BE_PRIVATE") static final Logger LOG = LoggerFactory.getLogger(TracingBroker.class); private static final int STACK_TRACE_FIRST_RELEVANT_FRAME = 2; diff --git a/opendaylight/md-sal/messagebus-impl/src/main/java/org/opendaylight/controller/messagebus/app/impl/EventSourceTopology.java b/opendaylight/md-sal/messagebus-impl/src/main/java/org/opendaylight/controller/messagebus/app/impl/EventSourceTopology.java index 934056dcab..50b8e4f459 100644 --- a/opendaylight/md-sal/messagebus-impl/src/main/java/org/opendaylight/controller/messagebus/app/impl/EventSourceTopology.java +++ b/opendaylight/md-sal/messagebus-impl/src/main/java/org/opendaylight/controller/messagebus/app/impl/EventSourceTopology.java @@ -110,7 +110,7 @@ public class EventSourceTopology implements EventAggregatorService, EventSourceR @Override public void onFailure(final Throwable ex) { - LOG.error("Can not put data into datastore [store: {}] [path: {}] [exception: {}]",store,path, ex); + LOG.error("Can not put data into datastore [store: {}] [path: {}]", store, path, ex); } }, MoreExecutors.directExecutor()); } @@ -127,7 +127,7 @@ public class EventSourceTopology implements EventAggregatorService, EventSourceR @Override public void onFailure(final Throwable ex) { - LOG.error("Can not delete data from datastore [store: {}] [path: {}] [exception: {}]",store,path, ex); + LOG.error("Can not delete data from datastore [store: {}] [path: {}]", store, path, ex); } }, MoreExecutors.directExecutor()); } diff --git a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/RaftActor.java b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/RaftActor.java index f9099a7b81..6cbeda6098 100755 --- a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/RaftActor.java +++ b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/RaftActor.java @@ -277,7 +277,7 @@ public abstract class RaftActor extends AbstractUntypedPersistentActor { // non-leader cannot satisfy leadership request LOG.warn("{}: onRequestLeadership {} was sent to non-leader." + " Current behavior: {}. Sending failure response", - persistenceId(), getCurrentBehavior().state()); + persistenceId(), message, getCurrentBehavior().state()); message.getReplyTo().tell(new LeadershipTransferFailedException("Cannot transfer leader to " + message.getRequestedFollowerId() + ". RequestLeadership message was sent to non-leader " + persistenceId()), getSelf()); diff --git a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/RaftActorContextImpl.java b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/RaftActorContextImpl.java index 19d796c936..9c8fbe496c 100644 --- a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/RaftActorContextImpl.java +++ b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/RaftActorContextImpl.java @@ -159,7 +159,7 @@ public class RaftActorContextImpl implements RaftActorContext { cluster = Optional.of(Cluster.get(getActorSystem())); } catch (Exception e) { // An exception means there's no cluster configured. This will only happen in unit tests. - log.debug("{}: Could not obtain Cluster: {}", getId(), e); + log.debug("{}: Could not obtain Cluster", getId(), e); cluster = Optional.empty(); } } diff --git a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/RaftActorRecoverySupport.java b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/RaftActorRecoverySupport.java index 1b9343c1f3..f071d94566 100644 --- a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/RaftActorRecoverySupport.java +++ b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/RaftActorRecoverySupport.java @@ -46,7 +46,7 @@ class RaftActorRecoverySupport { this.log = context.getLogger(); } - boolean handleRecoveryMessage(Object message, PersistentDataProvider persistentProvider) { + boolean handleRecoveryMessage(final Object message, final PersistentDataProvider persistentProvider) { log.trace("{}: handleRecoveryMessage: {}", context.getId(), message); anyDataRecovered = anyDataRecovered || !(message instanceof RecoveryCompleted); @@ -105,7 +105,7 @@ class RaftActorRecoverySupport { } } - private void onRecoveredSnapshot(SnapshotOffer offer) { + private void onRecoveredSnapshot(final SnapshotOffer offer) { log.debug("{}: SnapshotOffer called.", context.getId()); initRecoveryTimer(); @@ -153,7 +153,7 @@ class RaftActorRecoverySupport { replicatedLog().getSnapshotTerm(), replicatedLog().size()); } - private void onRecoveredJournalLogEntry(ReplicatedLogEntry logEntry) { + private void onRecoveredJournalLogEntry(final ReplicatedLogEntry logEntry) { if (log.isDebugEnabled()) { log.debug("{}: Received ReplicatedLogEntry for recovery: index: {}, size: {}", context.getId(), logEntry.getIndex(), logEntry.size()); @@ -174,7 +174,7 @@ class RaftActorRecoverySupport { } } - private void onRecoveredApplyLogEntries(long toIndex) { + private void onRecoveredApplyLogEntries(final long toIndex) { if (!context.getPersistenceProvider().isRecoveryApplicable()) { dataRecoveredWithPersistenceDisabled = true; return; @@ -206,7 +206,7 @@ class RaftActorRecoverySupport { context.setCommitIndex(lastApplied); } - private void onDeleteEntries(DeleteEntries deleteEntries) { + private void onDeleteEntries(final DeleteEntries deleteEntries) { if (context.getPersistenceProvider().isRecoveryApplicable()) { replicatedLog().removeFrom(deleteEntries.getFromIndex()); } else { @@ -214,7 +214,7 @@ class RaftActorRecoverySupport { } } - private void batchRecoveredLogEntry(ReplicatedLogEntry logEntry) { + private void batchRecoveredLogEntry(final ReplicatedLogEntry logEntry) { initRecoveryTimer(); int batchSize = context.getConfigParams().getJournalRecoveryLogBatchSize(); @@ -236,7 +236,7 @@ class RaftActorRecoverySupport { currentRecoveryBatchCount = 0; } - private void onRecoveryCompletedMessage(PersistentDataProvider persistentProvider) { + private void onRecoveryCompletedMessage(final PersistentDataProvider persistentProvider) { if (currentRecoveryBatchCount > 0) { endCurrentLogRecoveryBatch(); } @@ -248,9 +248,9 @@ class RaftActorRecoverySupport { recoveryTimer = null; } - log.info("Recovery completed" + recoveryTime + " - Switching actor to Follower - " + "Persistence Id = " - + context.getId() + " Last index in log = {}, snapshotIndex = {}, snapshotTerm = {}, " - + "journal-size = {}", replicatedLog().lastIndex(), replicatedLog().getSnapshotIndex(), + log.info("Recovery completed {} - Switching actor to Follower - Persistence Id = {}" + + " Last index in log = {}, snapshotIndex = {}, snapshotTerm = {}, journal-size = {}", + recoveryTime, context.getId(), replicatedLog().lastIndex(), replicatedLog().getSnapshotIndex(), replicatedLog().getSnapshotTerm(), replicatedLog().size()); if (dataRecoveredWithPersistenceDisabled @@ -284,19 +284,19 @@ class RaftActorRecoverySupport { } } - private static boolean isServerConfigurationPayload(ReplicatedLogEntry repLogEntry) { + private static boolean isServerConfigurationPayload(final ReplicatedLogEntry repLogEntry) { return repLogEntry.getData() instanceof ServerConfigurationPayload; } - private static boolean isPersistentPayload(ReplicatedLogEntry repLogEntry) { + private static boolean isPersistentPayload(final ReplicatedLogEntry repLogEntry) { return repLogEntry.getData() instanceof PersistentPayload; } - private static boolean isMigratedPayload(ReplicatedLogEntry repLogEntry) { + private static boolean isMigratedPayload(final ReplicatedLogEntry repLogEntry) { return isMigratedSerializable(repLogEntry.getData()); } - private static boolean isMigratedSerializable(Object message) { + private static boolean isMigratedSerializable(final Object message) { return message instanceof MigratedSerializable && ((MigratedSerializable)message).isMigrated(); } } diff --git a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/behaviors/AbstractRaftActorBehavior.java b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/behaviors/AbstractRaftActorBehavior.java index e8c1b09772..400f110865 100644 --- a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/behaviors/AbstractRaftActorBehavior.java +++ b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/behaviors/AbstractRaftActorBehavior.java @@ -11,6 +11,7 @@ package org.opendaylight.controller.cluster.raft.behaviors; import akka.actor.ActorRef; import akka.actor.Cancellable; import com.google.common.base.Preconditions; +import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import java.util.Random; import java.util.concurrent.TimeUnit; import org.opendaylight.controller.cluster.raft.ClientRequestTracker; @@ -39,6 +40,7 @@ public abstract class AbstractRaftActorBehavior implements RaftActorBehavior { /** * Used for message logging. */ + @SuppressFBWarnings("SLF4J_LOGGER_SHOULD_BE_PRIVATE") protected final Logger log; /** @@ -96,7 +98,7 @@ public abstract class AbstractRaftActorBehavior implements RaftActorBehavior { } @Override - public void setReplicatedToAllIndex(long replicatedToAllIndex) { + public void setReplicatedToAllIndex(final long replicatedToAllIndex) { this.replicatedToAllIndex = replicatedToAllIndex; } @@ -127,7 +129,7 @@ public abstract class AbstractRaftActorBehavior implements RaftActorBehavior { * @param appendEntries the message * @return a new behavior if it was changed or the current behavior */ - protected RaftActorBehavior appendEntries(ActorRef sender, AppendEntries appendEntries) { + protected RaftActorBehavior appendEntries(final ActorRef sender, final AppendEntries appendEntries) { // 1. Reply false if term < currentTerm (§5.1) if (appendEntries.getTerm() < currentTerm()) { @@ -165,7 +167,7 @@ public abstract class AbstractRaftActorBehavior implements RaftActorBehavior { * @param requestVote the message * @return a new behavior if it was changed or the current behavior */ - protected RaftActorBehavior requestVote(ActorRef sender, RequestVote requestVote) { + protected RaftActorBehavior requestVote(final ActorRef sender, final RequestVote requestVote) { log.debug("{}: In requestVote: {} - currentTerm: {}, votedFor: {}, lastIndex: {}, lastTerm: {}", logName(), requestVote, currentTerm(), votedFor(), lastIndex(), lastTerm()); @@ -185,7 +187,7 @@ public abstract class AbstractRaftActorBehavior implements RaftActorBehavior { return this; } - protected boolean canGrantVote(RequestVote requestVote) { + protected boolean canGrantVote(final RequestVote requestVote) { boolean grantVote = false; // Reply false if term < currentTerm (§5.1) @@ -264,7 +266,7 @@ public abstract class AbstractRaftActorBehavior implements RaftActorBehavior { * * @param interval the duration after which we should trigger a new election */ - protected void scheduleElection(FiniteDuration interval) { + protected void scheduleElection(final FiniteDuration interval) { stopElection(); // Schedule an election. When the scheduler triggers an ElectionTimeout message is sent to itself @@ -322,7 +324,7 @@ public abstract class AbstractRaftActorBehavior implements RaftActorBehavior { * @param logIndex the log index * @return the ClientRequestTracker or null if none available */ - protected ClientRequestTracker removeClientRequestTracker(long logIndex) { + protected ClientRequestTracker removeClientRequestTracker(final long logIndex) { return null; } @@ -331,7 +333,7 @@ public abstract class AbstractRaftActorBehavior implements RaftActorBehavior { * * @return the log entry index or -1 if not found */ - protected long getLogEntryIndex(long index) { + protected long getLogEntryIndex(final long index) { if (index == context.getReplicatedLog().getSnapshotIndex()) { return context.getReplicatedLog().getSnapshotIndex(); } @@ -349,7 +351,7 @@ public abstract class AbstractRaftActorBehavior implements RaftActorBehavior { * * @return the log entry term or -1 if not found */ - protected long getLogEntryTerm(long index) { + protected long getLogEntryTerm(final long index) { if (index == context.getReplicatedLog().getSnapshotIndex()) { return context.getReplicatedLog().getSnapshotTerm(); } @@ -405,7 +407,7 @@ public abstract class AbstractRaftActorBehavior implements RaftActorBehavior { } @Override - public RaftActorBehavior handleMessage(ActorRef sender, Object message) { + public RaftActorBehavior handleMessage(final ActorRef sender, final Object message) { if (message instanceof AppendEntries) { return appendEntries(sender, (AppendEntries) message); } else if (message instanceof AppendEntriesReply) { @@ -420,16 +422,16 @@ public abstract class AbstractRaftActorBehavior implements RaftActorBehavior { } @Override - public RaftActorBehavior switchBehavior(RaftActorBehavior behavior) { + public RaftActorBehavior switchBehavior(final RaftActorBehavior behavior) { return internalSwitchBehavior(behavior); } - protected RaftActorBehavior internalSwitchBehavior(RaftState newState) { + protected RaftActorBehavior internalSwitchBehavior(final RaftState newState) { return internalSwitchBehavior(createBehavior(context, newState)); } @SuppressWarnings("checkstyle:IllegalCatch") - protected RaftActorBehavior internalSwitchBehavior(RaftActorBehavior newBehavior) { + protected RaftActorBehavior internalSwitchBehavior(final RaftActorBehavior newBehavior) { if (!context.getRaftPolicy().automaticElectionsEnabled()) { return this; } @@ -445,7 +447,7 @@ public abstract class AbstractRaftActorBehavior implements RaftActorBehavior { } - protected int getMajorityVoteCount(int numPeers) { + protected int getMajorityVoteCount(final int numPeers) { // Votes are required from a majority of the peers including self. // The numMajority field therefore stores a calculated value // of the number of votes required for this candidate to win an diff --git a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/behaviors/SyncStatusTracker.java b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/behaviors/SyncStatusTracker.java index e2512d5b67..20714493e8 100644 --- a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/behaviors/SyncStatusTracker.java +++ b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/behaviors/SyncStatusTracker.java @@ -68,7 +68,7 @@ public class SyncStatusTracker { LOG.debug("{}: Lagging {} entries behind leader {}", id, lag, leaderId); changeSyncStatus(NOT_IN_SYNC, false); } else if (commitIndex >= syncTarget.minimumCommitIndex) { - LOG.debug("{}: Lagging {} entries behind leader and reached {} (of expected {})", id, lag, leaderId, + LOG.debug("{}: Lagging {} entries behind leader {} and reached {} (of expected {})", id, lag, leaderId, commitIndex, syncTarget.minimumCommitIndex); changeSyncStatus(IN_SYNC, false); } diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/compat/HeliumNotificationProviderServiceAdapter.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/compat/HeliumNotificationProviderServiceAdapter.java index 149c2c2dab..ac85f65b77 100644 --- a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/compat/HeliumNotificationProviderServiceAdapter.java +++ b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/compat/HeliumNotificationProviderServiceAdapter.java @@ -22,8 +22,8 @@ public class HeliumNotificationProviderServiceAdapter extends HeliumNotification private final NotificationPublishService notificationPublishService; - public HeliumNotificationProviderServiceAdapter(NotificationPublishService notificationPublishService, - NotificationService notificationService) { + public HeliumNotificationProviderServiceAdapter(final NotificationPublishService notificationPublishService, + final NotificationService notificationService) { super(notificationService); this.notificationPublishService = notificationPublishService; } @@ -33,7 +33,7 @@ public class HeliumNotificationProviderServiceAdapter extends HeliumNotification try { notificationPublishService.putNotification(notification); } catch (InterruptedException e) { - LOG.error("Notification publication was interupted: " + e); + LOG.error("Notification publication was interupted", e); } } @@ -42,17 +42,18 @@ public class HeliumNotificationProviderServiceAdapter extends HeliumNotification try { notificationPublishService.putNotification(notification); } catch (InterruptedException e) { - LOG.error("Notification publication was interupted: " + e); + LOG.error("Notification publication was interupted", e); } } @Override public ListenerRegistration registerInterestListener( - NotificationInterestListener interestListener) { + final NotificationInterestListener interestListener) { throw new UnsupportedOperationException("InterestListener is not supported."); } @Override - public void close() throws Exception { + public void close() { + } } diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/compat/HeliumNotificationProviderServiceWithInterestListeners.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/compat/HeliumNotificationProviderServiceWithInterestListeners.java index ee64e47080..2a07b03b83 100644 --- a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/compat/HeliumNotificationProviderServiceWithInterestListeners.java +++ b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/compat/HeliumNotificationProviderServiceWithInterestListeners.java @@ -68,7 +68,7 @@ public class HeliumNotificationProviderServiceWithInterestListeners extends Heli try { notifyListener(listenerRef, baEvent); } catch (RuntimeException e) { - LOG.warn("Unhandled exception during invoking listener {}", e, listenerRef); + LOG.warn("Unhandled exception during invoking listener {}", listenerRef, e); } } } @@ -90,7 +90,7 @@ public class HeliumNotificationProviderServiceWithInterestListeners extends Heli }; } - private void notifyListener(final NotificationInterestListener listener, + private static void notifyListener(final NotificationInterestListener listener, final Set> baEvent) { for (final Class event: baEvent) { listener.onNotificationSubscribtion(event); @@ -114,7 +114,7 @@ public class HeliumNotificationProviderServiceWithInterestListeners extends Heli } @Override - public void close() throws Exception { + public void close() { super.close(); domListener.close(); } diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingDOMMountPointListenerAdapter.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingDOMMountPointListenerAdapter.java index a929af5bcf..69e6d99a29 100644 --- a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingDOMMountPointListenerAdapter.java +++ b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingDOMMountPointListenerAdapter.java @@ -16,9 +16,12 @@ import org.opendaylight.yangtools.yang.binding.DataObject; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.data.impl.codec.DeserializationException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; final class BindingDOMMountPointListenerAdapter implements ListenerRegistration, DOMMountPointListener { + private static final Logger LOG = LoggerFactory.getLogger(BindingDOMMountPointListenerAdapter.class); private final T listener; private final ListenerRegistration registration; @@ -47,8 +50,7 @@ final class BindingDOMMountPointListenerAdapter final InstanceIdentifier bindingPath = toBinding(path); listener.onMountPointCreated(bindingPath); } catch (final DeserializationException e) { - BindingDOMMountPointServiceAdapter.LOG.error("Unable to translate mountPoint path {}. Omitting event.", - path, e); + LOG.error("Unable to translate mountPoint path {}. Omitting event.", path, e); } } @@ -69,8 +71,7 @@ final class BindingDOMMountPointListenerAdapter final InstanceIdentifier bindingPath = toBinding(path); listener.onMountPointRemoved(bindingPath); } catch (final DeserializationException e) { - BindingDOMMountPointServiceAdapter.LOG.error("Unable to translate mountPoint path {}. Omitting event.", - path, e); + LOG.error("Unable to translate mountPoint path {}. Omitting event.", path, e); } } } diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingDOMMountPointServiceAdapter.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingDOMMountPointServiceAdapter.java index 896d26ffc9..244ab51199 100644 --- a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingDOMMountPointServiceAdapter.java +++ b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingDOMMountPointServiceAdapter.java @@ -22,26 +22,26 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class BindingDOMMountPointServiceAdapter implements MountPointService { - public static final Logger LOG = LoggerFactory.getLogger(BindingDOMMountPointServiceAdapter.class); + private static final Logger LOG = LoggerFactory.getLogger(BindingDOMMountPointServiceAdapter.class); private final BindingToNormalizedNodeCodec codec; private final DOMMountPointService mountService; private final LoadingCache bindingMountpoints = CacheBuilder.newBuilder() .weakKeys().build(new CacheLoader() { - @Override - public BindingMountPointAdapter load(DOMMountPoint key) { - return new BindingMountPointAdapter(codec,key); + public BindingMountPointAdapter load(final DOMMountPoint key) { + return new BindingMountPointAdapter(codec, key); } }); - public BindingDOMMountPointServiceAdapter(DOMMountPointService mountService,BindingToNormalizedNodeCodec codec) { + public BindingDOMMountPointServiceAdapter(final DOMMountPointService mountService, + final BindingToNormalizedNodeCodec codec) { this.codec = codec; this.mountService = mountService; } @Override - public Optional getMountPoint(InstanceIdentifier mountPoint) { + public Optional getMountPoint(final InstanceIdentifier mountPoint) { YangInstanceIdentifier domPath = codec.toYangInstanceIdentifierBlocking(mountPoint); Optional domMount = mountService.getMountPoint(domPath); @@ -52,8 +52,8 @@ public class BindingDOMMountPointServiceAdapter implements MountPointService { } @Override - public ListenerRegistration registerListener(InstanceIdentifier path, - T listener) { + public ListenerRegistration registerListener(final InstanceIdentifier path, + final T listener) { return new BindingDOMMountPointListenerAdapter<>(listener, codec, mountService); } } diff --git a/opendaylight/md-sal/sal-cluster-admin-impl/src/main/java/org/opendaylight/controller/cluster/datastore/admin/ClusterAdminRpcService.java b/opendaylight/md-sal/sal-cluster-admin-impl/src/main/java/org/opendaylight/controller/cluster/datastore/admin/ClusterAdminRpcService.java index 5d9c1d61c3..1bff714179 100644 --- a/opendaylight/md-sal/sal-cluster-admin-impl/src/main/java/org/opendaylight/controller/cluster/datastore/admin/ClusterAdminRpcService.java +++ b/opendaylight/md-sal/sal-cluster-admin-impl/src/main/java/org/opendaylight/controller/cluster/datastore/admin/ClusterAdminRpcService.java @@ -20,6 +20,7 @@ import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.MoreExecutors; import com.google.common.util.concurrent.SettableFuture; +import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import java.io.FileOutputStream; import java.io.IOException; import java.util.AbstractMap.SimpleEntry; @@ -228,7 +229,7 @@ public class ClusterAdminRpcService implements ClusterAdminService { public void onComplete(final Throwable failure, final ActorRef actorRef) { if (failure != null) { LOG.warn("No local shard found for {} datastoreType {} - Cannot request leadership transfer to" - + " local shard.", shardName, failure); + + " local shard.", shardName, dataStoreType, failure); makeLeaderLocalAsk.failure(failure); } else { makeLeaderLocalAsk @@ -672,9 +673,10 @@ public class ClusterAdminRpcService implements ClusterAdminService { onMessageFailure(String.format("Failed to back up datastore to file %s", fileName), returnFuture, failure); } + @SuppressFBWarnings("SLF4J_SIGN_ONLY_FORMAT") private static void onMessageFailure(final String msg, final SettableFuture> returnFuture, final Throwable failure) { - LOG.error(msg, failure); + LOG.error("{}", msg, failure); returnFuture.set(ClusterAdminRpcService.newFailedRpcResultBuilder(String.format("%s: %s", msg, failure.getMessage())).build()); } diff --git a/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/common/actor/AbstractUntypedActor.java b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/common/actor/AbstractUntypedActor.java index 6bd7a053b0..c0e260ae66 100644 --- a/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/common/actor/AbstractUntypedActor.java +++ b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/common/actor/AbstractUntypedActor.java @@ -10,12 +10,14 @@ package org.opendaylight.controller.cluster.common.actor; import akka.actor.ActorRef; import akka.actor.UntypedActor; +import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import org.eclipse.jdt.annotation.NonNull; import org.slf4j.Logger; import org.slf4j.LoggerFactory; public abstract class AbstractUntypedActor extends UntypedActor implements ExecuteInSelfActor { // The member name should be lower case but it's referenced in many subclasses. Suppressing the CS warning for now. + @SuppressFBWarnings("SLF4J_LOGGER_SHOULD_BE_PRIVATE") @SuppressWarnings("checkstyle:MemberName") protected final Logger LOG = LoggerFactory.getLogger(getClass()); diff --git a/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/common/actor/AbstractUntypedPersistentActor.java b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/common/actor/AbstractUntypedPersistentActor.java index e9aaa65453..5ee3c49988 100644 --- a/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/common/actor/AbstractUntypedPersistentActor.java +++ b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/common/actor/AbstractUntypedPersistentActor.java @@ -10,6 +10,7 @@ package org.opendaylight.controller.cluster.common.actor; import akka.actor.ActorRef; import akka.persistence.UntypedPersistentActor; +import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import org.eclipse.jdt.annotation.NonNull; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -17,6 +18,7 @@ import org.slf4j.LoggerFactory; public abstract class AbstractUntypedPersistentActor extends UntypedPersistentActor implements ExecuteInSelfActor { // The member name should be lower case but it's referenced in many subclasses. Suppressing the CS warning for now. + @SuppressFBWarnings("SLF4J_LOGGER_SHOULD_BE_PRIVATE") @SuppressWarnings("checkstyle:MemberName") protected final Logger LOG = LoggerFactory.getLogger(getClass()); diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/akka/impl/ActorSystemProviderImpl.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/akka/impl/ActorSystemProviderImpl.java index 14aedffd2a..9d1126a783 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/akka/impl/ActorSystemProviderImpl.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/akka/impl/ActorSystemProviderImpl.java @@ -24,7 +24,8 @@ import scala.concurrent.duration.Duration; public class ActorSystemProviderImpl implements ActorSystemProvider, AutoCloseable { private static final String ACTOR_SYSTEM_NAME = "opendaylight-cluster-data"; - static final Logger LOG = LoggerFactory.getLogger(ActorSystemProviderImpl.class); + private static final Logger LOG = LoggerFactory.getLogger(ActorSystemProviderImpl.class); + private final ActorSystem actorSystem; private final ListenerRegistry listeners = new ListenerRegistry<>(); diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/actors/dds/ModuleShardBackendResolver.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/actors/dds/ModuleShardBackendResolver.java index ee549d3611..b79a5ab88e 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/actors/dds/ModuleShardBackendResolver.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/actors/dds/ModuleShardBackendResolver.java @@ -129,7 +129,7 @@ final class ModuleShardBackendResolver extends AbstractShardBackendResolver { LOG.debug("Invalidating backend information {}", staleInfo); flushCache(staleInfo.getShardName()); - LOG.trace("Invalidated cache %s", staleInfo); + LOG.trace("Invalidated cache {}", staleInfo); backends.remove(cookie, existing); } diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/actors/dds/SimpleShardBackendResolver.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/actors/dds/SimpleShardBackendResolver.java index 370484d955..9741a6bda4 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/actors/dds/SimpleShardBackendResolver.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/actors/dds/SimpleShardBackendResolver.java @@ -88,7 +88,7 @@ final class SimpleShardBackendResolver extends AbstractShardBackendResolver { synchronized (this) { LOG.debug("Invalidating backend information {}", staleInfo); flushCache(shardName); - LOG.trace("Invalidated cache %s", staleInfo); + LOG.trace("Invalidated cache {}", staleInfo); state = null; } } diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/actors/dds/SingleClientHistory.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/actors/dds/SingleClientHistory.java index 7c3bba9756..db57f1aed5 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/actors/dds/SingleClientHistory.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/actors/dds/SingleClientHistory.java @@ -19,7 +19,7 @@ import org.slf4j.LoggerFactory; * @author Robert Varga */ final class SingleClientHistory extends AbstractClientHistory { - private static final Logger LOG = LoggerFactory.getLogger(AbstractClientHistory.class); + private static final Logger LOG = LoggerFactory.getLogger(SingleClientHistory.class); SingleClientHistory(final AbstractDataStoreClientBehavior client, final LocalHistoryIdentifier identifier) { super(client, identifier); diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/AbstractShardDataTreeNotificationPublisherActorProxy.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/AbstractShardDataTreeNotificationPublisherActorProxy.java index fb3e968fe8..b4cdb81c5a 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/AbstractShardDataTreeNotificationPublisherActorProxy.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/AbstractShardDataTreeNotificationPublisherActorProxy.java @@ -10,6 +10,7 @@ package org.opendaylight.controller.cluster.datastore; import akka.actor.ActorContext; import akka.actor.ActorRef; import akka.actor.Props; +import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import javax.annotation.concurrent.NotThreadSafe; import org.opendaylight.controller.cluster.common.actor.Dispatchers; import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidate; @@ -24,6 +25,7 @@ import org.slf4j.LoggerFactory; */ @NotThreadSafe abstract class AbstractShardDataTreeNotificationPublisherActorProxy implements ShardDataTreeNotificationPublisher { + @SuppressFBWarnings("SLF4J_LOGGER_SHOULD_BE_PRIVATE") protected final Logger log = LoggerFactory.getLogger(getClass()); private final ActorContext actorContext; @@ -31,8 +33,8 @@ abstract class AbstractShardDataTreeNotificationPublisherActorProxy implements S private final String logContext; private ActorRef publisherActor; - protected AbstractShardDataTreeNotificationPublisherActorProxy(ActorContext actorContext, String actorName, - String logContext) { + protected AbstractShardDataTreeNotificationPublisherActorProxy(final ActorContext actorContext, + final String actorName, final String logContext) { this.actorContext = actorContext; this.actorName = actorName; this.logContext = logContext; @@ -49,7 +51,7 @@ abstract class AbstractShardDataTreeNotificationPublisherActorProxy implements S } @Override - public void publishChanges(DataTreeCandidate candidate) { + public void publishChanges(final DataTreeCandidate candidate) { publisherActor().tell(new ShardDataTreeNotificationPublisherActor.PublishNotifications(candidate), ActorRef.noSender()); } diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/CompositeDataTreeCohort.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/CompositeDataTreeCohort.java index 0ef49b6244..200f766b5d 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/CompositeDataTreeCohort.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/CompositeDataTreeCohort.java @@ -232,7 +232,7 @@ class CompositeDataTreeCohort { aggregateFuture.onComplete(new OnComplete>() { @Override - public void onComplete(Throwable failure, Iterable results) { + public void onComplete(final Throwable failure, final Iterable results) { callbackExecutor.execute( () -> processResponses(failure, results, currentState, afterState, returnFuture)); } @@ -244,8 +244,8 @@ class CompositeDataTreeCohort { // FB issues violation for passing null to CompletableFuture#complete but it is valid and necessary when the // generic type is Void. @SuppressFBWarnings("NP_NONNULL_PARAM_VIOLATION") - private void processResponses(Throwable failure, Iterable results, State currentState, State afterState, - CompletableFuture resultFuture) { + private void processResponses(final Throwable failure, final Iterable results, + final State currentState, final State afterState, final CompletableFuture resultFuture) { if (failure != null) { successfulFromPrevious = Collections.emptyList(); resultFuture.completeExceptionally(failure); @@ -260,7 +260,7 @@ class CompositeDataTreeCohort { } else if (result instanceof Status.Failure) { failed.add((Failure) result); } else { - LOG.warn("{}: unrecognized response {}, ignoring it", result); + LOG.warn("{}: unrecognized response {}, ignoring it", txId, result); } } diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/DataTreeChangeListenerProxy.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/DataTreeChangeListenerProxy.java index 0a33842808..a57a799284 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/DataTreeChangeListenerProxy.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/DataTreeChangeListenerProxy.java @@ -76,7 +76,7 @@ final class DataTreeChangeListenerProxy ext + "cannot be registered", logContext(), shardName, getInstance(), registeredPath); } else if (failure != null) { LOG.error("{}: Failed to find local shard {} - DataTreeChangeListener {} at path {} " - + "cannot be registered: {}", logContext(), shardName, getInstance(), registeredPath, + + "cannot be registered", logContext(), shardName, getInstance(), registeredPath, failure); } else { doRegistration(shard); diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/DataTreeCohortRegistrationProxy.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/DataTreeCohortRegistrationProxy.java index cfe12a1bc6..e14db0fe6a 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/DataTreeCohortRegistrationProxy.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/DataTreeCohortRegistrationProxy.java @@ -5,7 +5,6 @@ * 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.controller.cluster.datastore; import akka.actor.ActorRef; @@ -37,8 +36,8 @@ public class DataTreeCohortRegistrationProxy @GuardedBy("this") private ActorRef cohortRegistry; - - DataTreeCohortRegistrationProxy(ActorContext actorContext, DOMDataTreeIdentifier subtree, C cohort) { + DataTreeCohortRegistrationProxy(final ActorContext actorContext, final DOMDataTreeIdentifier subtree, + final C cohort) { super(cohort); this.subtree = Preconditions.checkNotNull(subtree); this.actorContext = Preconditions.checkNotNull(actorContext); @@ -46,8 +45,7 @@ public class DataTreeCohortRegistrationProxy subtree.getRootIdentifier()).withDispatcher(actorContext.getNotificationDispatcherPath())); } - - public void init(String shardName) { + public void init(final String shardName) { // FIXME: Add late binding to shard. Future findFuture = actorContext.findLocalShardAsync(shardName); findFuture.onComplete(new OnComplete() { @@ -58,7 +56,7 @@ public class DataTreeCohortRegistrationProxy + "cannot be registered", shardName, getInstance(), subtree); } else if (failure != null) { LOG.error("Failed to find local shard {} - DataTreeChangeListener {} at path {} " - + "cannot be registered: {}", shardName, getInstance(), subtree, failure); + + "cannot be registered", shardName, getInstance(), subtree, failure); } else { performRegistration(shard); } @@ -66,7 +64,7 @@ public class DataTreeCohortRegistrationProxy }, actorContext.getClientDispatcher()); } - private synchronized void performRegistration(ActorRef shard) { + private synchronized void performRegistration(final ActorRef shard) { if (isClosed()) { return; } @@ -76,7 +74,7 @@ public class DataTreeCohortRegistrationProxy future.onComplete(new OnComplete() { @Override - public void onComplete(Throwable failure, Object val) { + public void onComplete(final Throwable failure, final Object val) { if (failure != null) { LOG.error("Unable to register {} as commit cohort", getInstance(), failure); } diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/DebugThreePhaseCommitCohort.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/DebugThreePhaseCommitCohort.java index 53d2730f86..9f9d169d1a 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/DebugThreePhaseCommitCohort.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/DebugThreePhaseCommitCohort.java @@ -13,6 +13,7 @@ import com.google.common.util.concurrent.FutureCallback; import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.MoreExecutors; +import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import java.util.List; import org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier; import org.slf4j.Logger; @@ -31,6 +32,8 @@ class DebugThreePhaseCommitCohort extends AbstractThreePhaseCommitCohort private final AbstractThreePhaseCommitCohort delegate; private final Throwable debugContext; private final TransactionIdentifier transactionId; + + @SuppressFBWarnings("SLF4J_LOGGER_SHOULD_BE_FINAL") private Logger log = LOG; DebugThreePhaseCommitCohort(final TransactionIdentifier transactionId, diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/FrontendClientMetadataBuilder.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/FrontendClientMetadataBuilder.java index 81b782d236..5de977da13 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/FrontendClientMetadataBuilder.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/FrontendClientMetadataBuilder.java @@ -108,7 +108,7 @@ final class FrontendClientMetadataBuilder implements Builder initiateCoordinatedCommit(Optional> participatingShardNames) { + Future initiateCoordinatedCommit(final Optional> participatingShardNames) { final Future messageFuture = initiateCommit(false, participatingShardNames); final Future ret = TransactionReadyReplyMapper.transform(messageFuture, actorContext, transaction.getIdentifier()); @@ -104,7 +104,8 @@ class LocalThreePhaseCommitCohort implements DOMStoreThreePhaseCommitCohort { LOG.debug("Transaction {} committed successfully", transaction.getIdentifier()); transactionCommitted(transaction); } else { - LOG.error("Transaction {} resulted in unhandled message type {}, aborting", message.getClass()); + LOG.error("Transaction {} resulted in unhandled message type {}, aborting", + transaction.getIdentifier(), message.getClass()); transactionAborted(transaction); } } @@ -137,9 +138,9 @@ class LocalThreePhaseCommitCohort implements DOMStoreThreePhaseCommitCohort { throw new UnsupportedOperationException(); } - protected void transactionAborted(SnapshotBackedWriteTransaction aborted) { + protected void transactionAborted(final SnapshotBackedWriteTransaction aborted) { } - protected void transactionCommitted(SnapshotBackedWriteTransaction comitted) { + protected void transactionCommitted(final SnapshotBackedWriteTransaction comitted) { } } diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/NoOpTransactionContext.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/NoOpTransactionContext.java index 03ed5ad0ea..89a8c03c6a 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/NoOpTransactionContext.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/NoOpTransactionContext.java @@ -38,14 +38,14 @@ final class NoOpTransactionContext extends AbstractTransactionContext { @Override public Future directCommit(final Boolean havePermit) { - LOG.debug("Tx {} directCommit called, failure: {}", getIdentifier(), failure); + LOG.debug("Tx {} directCommit called, failure", getIdentifier(), failure); return akka.dispatch.Futures.failed(failure); } @Override public Future readyTransaction(final Boolean havePermit, final Optional> participatingShardNamess) { - LOG.debug("Tx {} readyTransaction called, failure: {}", getIdentifier(), failure); + LOG.debug("Tx {} readyTransaction called, failure", getIdentifier(), failure); return akka.dispatch.Futures.failed(failure); } diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/RemoteTransactionContext.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/RemoteTransactionContext.java index 52057faa4b..b7c1705688 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/RemoteTransactionContext.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/RemoteTransactionContext.java @@ -240,8 +240,8 @@ public class RemoteTransactionContext extends AbstractTransactionContext { } if (failure != null) { - LOG.debug("Tx {} {} operation failed: {}", getIdentifier(), readCmd.getClass().getSimpleName(), - failure); + LOG.debug("Tx {} {} operation failed", getIdentifier(), readCmd.getClass().getSimpleName(), + failure); returnFuture.setException(new ReadFailedException("Error checking " + readCmd.getClass().getSimpleName() + " for path " + readCmd.getPath(), failure)); diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardCommitCoordinator.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardCommitCoordinator.java index eebad9ce06..403a96819f 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardCommitCoordinator.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardCommitCoordinator.java @@ -251,8 +251,8 @@ final class ShardCommitCoordinator { @Override public void onFailure(final Throwable failure) { - log.debug("{}: An exception occurred during canCommit for {}: {}", name, - cohortEntry.getTransactionId(), failure); + log.debug("{}: An exception occurred during canCommit for {}", name, cohortEntry.getTransactionId(), + failure); cohortCache.remove(cohortEntry.getTransactionId()); cohortEntry.getReplySender().tell(new Failure(failure), cohortEntry.getShard().self()); @@ -276,7 +276,7 @@ final class ShardCommitCoordinator { // between canCommit and ready and the entry was expired from the cache or it was aborted. IllegalStateException ex = new IllegalStateException( String.format("%s: Cannot canCommit transaction %s - no cohort entry found", name, transactionID)); - log.error(ex.getMessage()); + log.error("{}: Inconsistency during transaction {} canCommit", name, transactionID, ex); sender.tell(new Failure(ex), shard.self()); return; } @@ -353,7 +353,7 @@ final class ShardCommitCoordinator { // or it was aborted. IllegalStateException ex = new IllegalStateException( String.format("%s: Cannot commit transaction %s - no cohort entry found", name, transactionID)); - log.error(ex.getMessage()); + log.error("{}: Inconsistency during transaction {} commit", name, transactionID, ex); sender.tell(new Failure(ex), shard.self()); return; } diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardDataTree.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardDataTree.java index e1c12cd489..c37703c335 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardDataTree.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardDataTree.java @@ -738,8 +738,8 @@ public class ShardDataTree extends ShardDataTreeTransactionParent { // For debugging purposes, allow dumping of the modification. Coupled with the above // precondition log, it should allow us to understand what went on. - LOG.debug("{}: Store Tx {}: modifications: {} tree: {}", cohort.getIdentifier(), modification, - dataTree); + LOG.debug("{}: Store Tx {}: modifications: {} tree: {}", logContext, cohort.getIdentifier(), + modification, dataTree); cause = new TransactionCommitFailedException("Data did not pass validation for path " + e.getPath(), e); } catch (Exception e) { LOG.warn("{}: Unexpected failure in validation phase", logContext, e); @@ -873,7 +873,7 @@ public class ShardDataTree extends ShardDataTreeTransactionParent { processNextPendingTransaction(); } - private void insertEntry(Deque queue, CommitEntry entry, int atIndex) { + private void insertEntry(final Deque queue, final CommitEntry entry, final int atIndex) { if (atIndex == 0) { queue.addFirst(entry); return; @@ -892,7 +892,7 @@ public class ShardDataTree extends ShardDataTreeTransactionParent { } private Collection extractPrecedingShardNames( - java.util.Optional> participatingShardNames) { + final java.util.Optional> participatingShardNames) { return participatingShardNames.map((Function, Collection>) set -> set.headSet(shard.getShardName())).orElse(Collections.emptyList()); } diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardRecoveryCoordinator.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardRecoveryCoordinator.java index 5fc3c7adc2..7ece110d01 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardRecoveryCoordinator.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardRecoveryCoordinator.java @@ -119,7 +119,7 @@ abstract class ShardRecoveryCoordinator implements RaftActorRecoveryCohort { @SuppressWarnings("checkstyle:IllegalCatch") public void applyRecoverySnapshot(final Snapshot.State snapshotState) { if (!(snapshotState instanceof ShardSnapshotState)) { - log.debug("{}: applyRecoverySnapshot ignoring snapshot: {}", snapshotState); + log.debug("{}: applyRecoverySnapshot ignoring snapshot: {}", shardName, snapshotState); } log.debug("{}: Applying recovered snapshot", shardName); diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardSnapshotCohort.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardSnapshotCohort.java index d8c49a9e74..3ed3a48770 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardSnapshotCohort.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardSnapshotCohort.java @@ -75,7 +75,7 @@ final class ShardSnapshotCohort implements RaftActorSnapshotCohort { @SuppressWarnings("checkstyle:IllegalCatch") public void applySnapshot(final Snapshot.State snapshotState) { if (!(snapshotState instanceof ShardSnapshotState)) { - log.debug("{}: applySnapshot ignoring snapshot: {}", snapshotState); + log.debug("{}: applySnapshot ignoring snapshot: {}", logId, snapshotState); } final ShardDataTreeSnapshot snapshot = ((ShardSnapshotState)snapshotState).getSnapshot(); diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ThreePhaseCommitCohortProxy.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ThreePhaseCommitCohortProxy.java index a78b9a2ef6..4d80d7fd8a 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ThreePhaseCommitCohortProxy.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ThreePhaseCommitCohortProxy.java @@ -291,7 +291,7 @@ public class ThreePhaseCommitCohortProxy extends AbstractThreePhaseCommitCohort< @Override public void onFailure(final Throwable failure) { - LOG.debug("Tx {}: a {} cohort path Future failed: {}", transactionId, operationName, failure); + LOG.debug("Tx {}: a {} cohort path Future failed", transactionId, operationName, failure); if (propagateException) { returnFuture.setException(failure); diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/TransactionContextCleanup.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/TransactionContextCleanup.java index d4b52e5252..ef8cc49582 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/TransactionContextCleanup.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/TransactionContextCleanup.java @@ -54,7 +54,7 @@ final class TransactionContextCleanup extends FinalizablePhantomReference onLocalShardFound.accept((LocalShardFound) response), sender); } else if (response instanceof LocalShardNotFound) { - String msg = String.format("Local shard %s does not exist", shardName); - LOG.debug("{}: {}", persistenceId, msg); - sender.tell(new Status.Failure(new IllegalArgumentException(msg)), self()); + LOG.debug("{}: Local shard {} does not exist", persistenceId, shardName); + sender.tell(new Status.Failure(new IllegalArgumentException( + String.format("Local shard %s does not exist", shardName))), self()); } else { - String msg = String.format("Failed to find local shard %s: received response: %s", - shardName, response); - LOG.debug("{}: {}", persistenceId, msg); - sender.tell(new Status.Failure(response instanceof Throwable ? (Throwable) response : - new RuntimeException(msg)), self()); + LOG.debug("{}: Failed to find local shard {}: received response: {}", persistenceId, shardName, + response); + sender.tell(new Status.Failure(response instanceof Throwable ? (Throwable) response + : new RuntimeException( + String.format("Failed to find local shard %s: received response: %s", shardName, + response))), self()); } } } @@ -1795,10 +1799,11 @@ class ShardManager extends AbstractUntypedPersistentActorWithMetering { public void onComplete(final Throwable failure, final Object response) { shardReplicaOperationsInProgress.remove(shardName); if (failure != null) { - String msg = String.format("ChangeServersVotingStatus request to local shard %s failed", - shardActorRef.path()); - LOG.debug("{}: {}", persistenceId(), msg, failure); - sender.tell(new Status.Failure(new RuntimeException(msg, failure)), self()); + LOG.debug("{}: ChangeServersVotingStatus request to local shard {} failed", persistenceId(), + shardActorRef.path(), failure); + sender.tell(new Status.Failure(new RuntimeException( + String.format("ChangeServersVotingStatus request to local shard %s failed", + shardActorRef.path()), failure)), self()); } else { LOG.debug("{}: Received {} from local shard {}", persistenceId(), response, shardActorRef.path()); @@ -1960,11 +1965,11 @@ class ShardManager extends AbstractUntypedPersistentActorWithMetering { @Override public void onUnknownResponse(final Object response) { - String msg = String.format("Failed to find leader for shard %s: received response: %s", - shardName, response); - LOG.debug("{}: {}", persistenceId, msg); - targetActor.tell(new Status.Failure(response instanceof Throwable ? (Throwable) response : - new RuntimeException(msg)), shardManagerActor); + LOG.debug("{}: Failed to find leader for shard {}: received response: {}", persistenceId, shardName, + response); + targetActor.tell(new Status.Failure(response instanceof Throwable ? (Throwable) response + : new RuntimeException(String.format("Failed to find leader for shard %s: received response: %s", + shardName, response))), shardManagerActor); } } diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/shardmanager/ShardManagerGetSnapshotReplyActor.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/shardmanager/ShardManagerGetSnapshotReplyActor.java index 21af2c4969..ed384fd2c7 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/shardmanager/ShardManagerGetSnapshotReplyActor.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/shardmanager/ShardManagerGetSnapshotReplyActor.java @@ -60,12 +60,13 @@ final class ShardManagerGetSnapshotReplyActor extends UntypedAbstractActor { params.replyToActor.tell(message, getSelf()); getSelf().tell(PoisonPill.getInstance(), getSelf()); } else if (message instanceof ReceiveTimeout) { - String msg = String.format( - "Timed out after %s ms while waiting for snapshot replies from %d shard(s). %d shard(s) %s " - + "did not respond.", params.receiveTimeout.toMillis(), params.shardNames.size(), - remainingShardNames.size(), remainingShardNames); - LOG.warn("{}: {}", params.id, msg); - params.replyToActor.tell(new Failure(new TimeoutException(msg)), getSelf()); + LOG.warn("{}: Timed out after {} ms while waiting for snapshot replies from {} shard(s). " + + "{} shard(s) {} did not respond", params.id, params.receiveTimeout.toMillis(), + params.shardNames.size(), remainingShardNames.size(), remainingShardNames); + params.replyToActor.tell(new Failure(new TimeoutException(String.format( + "Timed out after %s ms while waiting for snapshot replies from %d shard(s). %d shard(s) %s " + + "did not respond.", params.receiveTimeout.toMillis(), params.shardNames.size(), + remainingShardNames.size(), remainingShardNames))), getSelf()); getSelf().tell(PoisonPill.getInstance(), getSelf()); } } diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/utils/ActorContext.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/utils/ActorContext.java index 2a47cae8b3..bba4d6140e 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/utils/ActorContext.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/utils/ActorContext.java @@ -75,7 +75,7 @@ public class ActorContext { private static final Mapper FIND_PRIMARY_FAILURE_TRANSFORMER = new Mapper() { @Override - public Throwable apply(Throwable failure) { + public Throwable apply(final Throwable failure) { Throwable actualFailure = failure; if (failure instanceof AskTimeoutException) { // A timeout exception most likely means the shard isn't initialized. @@ -115,15 +115,15 @@ public class ActorContext { private final PrimaryShardInfoFutureCache primaryShardInfoCache; private final ShardStrategyFactory shardStrategyFactory; - public ActorContext(ActorSystem actorSystem, ActorRef shardManager, - ClusterWrapper clusterWrapper, Configuration configuration) { + public ActorContext(final ActorSystem actorSystem, final ActorRef shardManager, + final ClusterWrapper clusterWrapper, final Configuration configuration) { this(actorSystem, shardManager, clusterWrapper, configuration, DatastoreContext.newBuilder().build(), new PrimaryShardInfoFutureCache()); } - public ActorContext(ActorSystem actorSystem, ActorRef shardManager, - ClusterWrapper clusterWrapper, Configuration configuration, - DatastoreContext datastoreContext, PrimaryShardInfoFutureCache primaryShardInfoCache) { + public ActorContext(final ActorSystem actorSystem, final ActorRef shardManager, + final ClusterWrapper clusterWrapper, final Configuration configuration, + final DatastoreContext datastoreContext, final PrimaryShardInfoFutureCache primaryShardInfoCache) { this.actorSystem = actorSystem; this.shardManager = shardManager; this.clusterWrapper = clusterWrapper; @@ -171,15 +171,15 @@ public class ActorContext { return shardManager; } - public ActorSelection actorSelection(String actorPath) { + public ActorSelection actorSelection(final String actorPath) { return actorSystem.actorSelection(actorPath); } - public ActorSelection actorSelection(ActorPath actorPath) { + public ActorSelection actorSelection(final ActorPath actorPath) { return actorSystem.actorSelection(actorPath); } - public void setSchemaContext(SchemaContext schemaContext) { + public void setSchemaContext(final SchemaContext schemaContext) { this.schemaContext = schemaContext; if (shardManager != null) { @@ -187,7 +187,7 @@ public class ActorContext { } } - public void setDatastoreContext(DatastoreContextFactory contextFactory) { + public void setDatastoreContext(final DatastoreContextFactory contextFactory) { this.datastoreContext = contextFactory.getBaseDatastoreContext(); setCachedProperties(); @@ -219,7 +219,7 @@ public class ActorContext { return future.transform(new Mapper() { @Override - public PrimaryShardInfo checkedApply(Object response) throws UnknownMessageException { + public PrimaryShardInfo checkedApply(final Object response) throws UnknownMessageException { if (response instanceof RemotePrimaryShardFound) { LOG.debug("findPrimaryShardAsync received: {}", response); RemotePrimaryShardFound found = (RemotePrimaryShardFound)response; @@ -243,8 +243,8 @@ public class ActorContext { }, FIND_PRIMARY_FAILURE_TRANSFORMER, getClientDispatcher()); } - private PrimaryShardInfo onPrimaryShardFound(String shardName, String primaryActorPath, - short primaryVersion, DataTree localShardDataTree) { + private PrimaryShardInfo onPrimaryShardFound(final String shardName, final String primaryActorPath, + final short primaryVersion, final DataTree localShardDataTree) { ActorSelection actorSelection = actorSystem.actorSelection(primaryActorPath); PrimaryShardInfo info = localShardDataTree == null ? new PrimaryShardInfo(actorSelection, primaryVersion) : new PrimaryShardInfo(actorSelection, primaryVersion, localShardDataTree); @@ -259,7 +259,7 @@ public class ActorContext { * @return a reference to a local shard actor which represents the shard * specified by the shardName */ - public Optional findLocalShard(String shardName) { + public Optional findLocalShard(final String shardName) { Object result = executeOperation(shardManager, new FindLocalShard(shardName, false)); if (result instanceof LocalShardFound) { @@ -283,7 +283,7 @@ public class ActorContext { return future.map(new Mapper() { @Override - public ActorRef checkedApply(Object response) throws Throwable { + public ActorRef checkedApply(final Object response) throws Throwable { if (response instanceof LocalShardFound) { LocalShardFound found = (LocalShardFound)response; LOG.debug("Local shard found {}", found.getPath()); @@ -309,7 +309,7 @@ public class ActorContext { * @return The response of the operation */ @SuppressWarnings("checkstyle:IllegalCatch") - public Object executeOperation(ActorRef actor, Object message) { + public Object executeOperation(final ActorRef actor, final Object message) { Future future = executeOperationAsync(actor, message, operationTimeout); try { @@ -328,7 +328,7 @@ public class ActorContext { * @return the response message */ @SuppressWarnings("checkstyle:IllegalCatch") - public Object executeOperation(ActorSelection actor, Object message) { + public Object executeOperation(final ActorSelection actor, final Object message) { Future future = executeOperationAsync(actor, message); try { @@ -339,7 +339,7 @@ public class ActorContext { } } - public Future executeOperationAsync(ActorRef actor, Object message, Timeout timeout) { + public Future executeOperationAsync(final ActorRef actor, final Object message, final Timeout timeout) { Preconditions.checkArgument(actor != null, "actor must not be null"); Preconditions.checkArgument(message != null, "message must not be null"); @@ -355,8 +355,8 @@ public class ActorContext { * @param timeout the operation timeout * @return a Future containing the eventual result */ - public Future executeOperationAsync(ActorSelection actor, Object message, - Timeout timeout) { + public Future executeOperationAsync(final ActorSelection actor, final Object message, + final Timeout timeout) { Preconditions.checkArgument(actor != null, "actor must not be null"); Preconditions.checkArgument(message != null, "message must not be null"); @@ -372,7 +372,7 @@ public class ActorContext { * @param message the message to send * @return a Future containing the eventual result */ - public Future executeOperationAsync(ActorSelection actor, Object message) { + public Future executeOperationAsync(final ActorSelection actor, final Object message) { return executeOperationAsync(actor, message, operationTimeout); } @@ -383,7 +383,7 @@ public class ActorContext { * @param actor the ActorSelection * @param message the message to send */ - public void sendOperationAsync(ActorSelection actor, Object message) { + public void sendOperationAsync(final ActorSelection actor, final Object message) { Preconditions.checkArgument(actor != null, "actor must not be null"); Preconditions.checkArgument(message != null, "message must not be null"); @@ -413,16 +413,16 @@ public class ActorContext { /** * Send the message to each and every shard. */ - public void broadcast(final Function messageSupplier, Class messageClass) { + public void broadcast(final Function messageSupplier, final Class messageClass) { for (final String shardName : configuration.getAllShardNames()) { Future primaryFuture = findPrimaryShardAsync(shardName); primaryFuture.onComplete(new OnComplete() { @Override - public void onComplete(Throwable failure, PrimaryShardInfo primaryShardInfo) { + public void onComplete(final Throwable failure, final PrimaryShardInfo primaryShardInfo) { if (failure != null) { - LOG.warn("broadcast failed to send message {} to shard {}: {}", - messageClass.getSimpleName(), shardName, failure); + LOG.warn("broadcast failed to send message {} to shard {}", messageClass.getSimpleName(), + shardName, failure); } else { Object message = messageSupplier.apply(primaryShardInfo.getPrimaryShardVersion()); primaryShardInfo.getPrimaryShardActor().tell(message, ActorRef.noSender()); @@ -440,7 +440,7 @@ public class ActorContext { return operationTimeout; } - public boolean isPathLocal(String path) { + public boolean isPathLocal(final String path) { if (Strings.isNullOrEmpty(path)) { return false; } @@ -474,11 +474,11 @@ public class ActorContext { * @param operationName the name of the operation * @return the Timer instance */ - public Timer getOperationTimer(String operationName) { + public Timer getOperationTimer(final String operationName) { return getOperationTimer(datastoreContext.getDataStoreName(), operationName); } - public Timer getOperationTimer(String dataStoreType, String operationName) { + public Timer getOperationTimer(final String dataStoreType, final String operationName) { final String rate = MetricRegistry.name(DISTRIBUTED_DATA_STORE_METRIC_REGISTRY, dataStoreType, operationName, METRIC_RATE); return metricRegistry.timer(rate); @@ -540,11 +540,11 @@ public class ActorContext { return shardStrategyFactory; } - protected Future doAsk(ActorRef actorRef, Object message, Timeout timeout) { + protected Future doAsk(final ActorRef actorRef, final Object message, final Timeout timeout) { return ask(actorRef, message, timeout); } - protected Future doAsk(ActorSelection actorRef, Object message, Timeout timeout) { + protected Future doAsk(final ActorSelection actorRef, final Object message, final Timeout timeout) { return ask(actorRef, message, timeout); } diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/SerializedDOMDataBroker.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/SerializedDOMDataBroker.java index db6192b348..c170944940 100644 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/SerializedDOMDataBroker.java +++ b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/SerializedDOMDataBroker.java @@ -73,7 +73,7 @@ public class SerializedDOMDataBroker extends AbstractDOMDataBroker { commitFuture = executor.submit(new CommitCoordinationTask<>(transaction, cohorts, commitStatsTracker, futureValueSupplier)); } catch (RejectedExecutionException e) { - LOG.error("The commit executor's queue is full - submit task was rejected. \n" + executor, e); + LOG.error("The commit executor {} queue is full - submit task was rejected. \n", executor, e); commitFuture = Futures.immediateFailedFuture(new TransactionCommitFailedException( "Could not submit the commit task - the commit queue capacity has been exceeded.", e)); } diff --git a/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/RpcInvoker.java b/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/RpcInvoker.java index 23b73f2094..4d3a66c00e 100644 --- a/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/RpcInvoker.java +++ b/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/RpcInvoker.java @@ -90,7 +90,7 @@ final class RpcInvoker extends AbstractUntypedActor { public void onFailure(final Throwable failure) { LOG.debug("Failed to execute RPC {}", msg.getRpc(), failure); LOG.error("Failed to execute RPC {} due to {}. More details are available on DEBUG level.", - msg.getRpc(), Throwables.getRootCause(failure)); + msg.getRpc(), Throwables.getRootCause(failure).getMessage()); sender.tell(new akka.actor.Status.Failure(failure), self); } }, MoreExecutors.directExecutor()); diff --git a/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/registry/gossip/BucketStoreActor.java b/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/registry/gossip/BucketStoreActor.java index a0f52d1b15..9a84b91300 100644 --- a/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/registry/gossip/BucketStoreActor.java +++ b/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/registry/gossip/BucketStoreActor.java @@ -377,7 +377,7 @@ public abstract class BucketStoreActor> extends versions.remove(addr); final Bucket bucket = remoteBuckets.remove(addr); if (bucket != null) { - LOG.debug("Source actor dead, removing bucket {} from ", bucket, addr); + LOG.debug("Source actor dead, removing bucket {} from {}", bucket, addr); onBucketRemoved(addr, bucket); } } diff --git a/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/registry/mbeans/RemoteRpcRegistryMXBeanImpl.java b/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/registry/mbeans/RemoteRpcRegistryMXBeanImpl.java index 22c18f085c..87adef3d9c 100644 --- a/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/registry/mbeans/RemoteRpcRegistryMXBeanImpl.java +++ b/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/registry/mbeans/RemoteRpcRegistryMXBeanImpl.java @@ -5,11 +5,11 @@ * 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.controller.remote.rpc.registry.mbeans; import akka.actor.Address; import akka.util.Timeout; +import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import java.util.HashMap; import java.util.HashSet; import java.util.Map; @@ -25,9 +25,9 @@ import org.slf4j.LoggerFactory; import scala.concurrent.Await; import scala.concurrent.Future; - public class RemoteRpcRegistryMXBeanImpl extends AbstractMXBean implements RemoteRpcRegistryMXBean { + @SuppressFBWarnings("SLF4J_LOGGER_SHOULD_BE_PRIVATE") protected final Logger log = LoggerFactory.getLogger(getClass()); private static final String LOCAL_CONSTANT = "local"; @@ -39,7 +39,7 @@ public class RemoteRpcRegistryMXBeanImpl extends AbstractMXBean implements Remot private final BucketStoreAccess rpcRegistryAccess; private final Timeout timeout; - public RemoteRpcRegistryMXBeanImpl(final BucketStoreAccess rpcRegistryAccess, Timeout timeout) { + public RemoteRpcRegistryMXBeanImpl(final BucketStoreAccess rpcRegistryAccess, final Timeout timeout) { super("RemoteRpcRegistry", "RemoteRpcBroker", null); this.rpcRegistryAccess = rpcRegistryAccess; this.timeout = timeout; diff --git a/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/listener/PeopleCarListener.java b/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/listener/PeopleCarListener.java index d76d0c7aba..60bfc5644f 100644 --- a/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/listener/PeopleCarListener.java +++ b/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/listener/PeopleCarListener.java @@ -60,7 +60,7 @@ public class PeopleCarListener implements CarPurchaseListener { @Override public void onFailure(final Throwable ex) { - LOG.error(String.format("Failed to add car-person entry: [%s]", carPerson), ex); + LOG.error("Failed to add car-person entry: [{}]", carPerson, ex); } }, MoreExecutors.directExecutor()); } diff --git a/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/CarProvider.java b/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/CarProvider.java index 13349d95e3..a6f154bfcd 100644 --- a/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/CarProvider.java +++ b/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/CarProvider.java @@ -13,6 +13,7 @@ import com.google.common.util.concurrent.FutureCallback; import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.MoreExecutors; +import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import java.util.Collection; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; @@ -76,6 +77,7 @@ import org.slf4j.LoggerFactory; * * @author Thomas Pantelis */ +@SuppressFBWarnings("SLF4J_ILLEGAL_PASSED_CLASS") public class CarProvider implements CarService { private static final Logger LOG_PURCHASE_CAR = LoggerFactory.getLogger(PurchaseCarProvider.class); diff --git a/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/PeopleProvider.java b/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/PeopleProvider.java index 2cd5d2b7bb..5e6e531436 100644 --- a/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/PeopleProvider.java +++ b/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/PeopleProvider.java @@ -75,7 +75,7 @@ public class PeopleProvider implements PeopleService, AutoCloseable { @Override public void onFailure(final Throwable ex) { - LOG.error(String.format("RPC addPerson : person addition failed [%s]", person), ex); + LOG.error("RPC addPerson : person addition failed [{}]", person, ex); futureResult.set(RpcResultBuilder.failed() .withError(RpcError.ErrorType.APPLICATION, ex.getMessage()).build()); } diff --git a/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/impl/IdIntsListener.java b/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/impl/IdIntsListener.java index 3e644393f1..3fdc446542 100644 --- a/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/impl/IdIntsListener.java +++ b/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/impl/IdIntsListener.java @@ -47,7 +47,7 @@ public class IdIntsListener implements ClusteredDOMDataTreeChangeListener { changes.forEach(change -> { if (change.getRootNode().getDataAfter().isPresent()) { - LOG.trace("Received change, data before: {}, data after: ", + LOG.trace("Received change, data before: {}, data after: {}", change.getRootNode().getDataBefore().isPresent() ? change.getRootNode().getDataBefore().get() : "", change.getRootNode().getDataAfter().get()); diff --git a/opendaylight/md-sal/samples/toaster-consumer/src/main/java/org/opendaylight/controller/sample/kitchen/impl/KitchenServiceImpl.java b/opendaylight/md-sal/samples/toaster-consumer/src/main/java/org/opendaylight/controller/sample/kitchen/impl/KitchenServiceImpl.java index c1c43f7676..b9b9b3d678 100644 --- a/opendaylight/md-sal/samples/toaster-consumer/src/main/java/org/opendaylight/controller/sample/kitchen/impl/KitchenServiceImpl.java +++ b/opendaylight/md-sal/samples/toaster-consumer/src/main/java/org/opendaylight/controller/sample/kitchen/impl/KitchenServiceImpl.java @@ -120,13 +120,12 @@ public class KitchenServiceImpl extends AbstractMXBean if (result.isSuccessful()) { LOG.info("makeBreakfast succeeded"); } else { - LOG.warn("makeBreakfast failed: " + result.getErrors()); + LOG.warn("makeBreakfast failed: {}", result.getErrors()); } return result.isSuccessful(); - } catch (InterruptedException | ExecutionException e) { - LOG.warn("An error occurred while maing breakfast: " + e); + LOG.warn("An error occurred while maing breakfast", e); } return Boolean.FALSE; @@ -146,7 +145,7 @@ public class KitchenServiceImpl extends AbstractMXBean */ @Override public void onToasterRestocked(final ToasterRestocked notification) { - LOG.info("ToasterRestocked notification - amountOfBread: " + notification.getAmountOfBread()); + LOG.info("ToasterRestocked notification - amountOfBread: {}", notification.getAmountOfBread()); toasterOutOfBread = false; } } diff --git a/opendaylight/md-sal/samples/toaster-provider/src/main/java/org/opendaylight/controller/sample/toaster/provider/OpendaylightToaster.java b/opendaylight/md-sal/samples/toaster-provider/src/main/java/org/opendaylight/controller/sample/toaster/provider/OpendaylightToaster.java index 0fcd474d9c..fc1e380a4c 100644 --- a/opendaylight/md-sal/samples/toaster-provider/src/main/java/org/opendaylight/controller/sample/toaster/provider/OpendaylightToaster.java +++ b/opendaylight/md-sal/samples/toaster-provider/src/main/java/org/opendaylight/controller/sample/toaster/provider/OpendaylightToaster.java @@ -215,7 +215,7 @@ public class OpendaylightToaster extends AbstractMXBean */ @Override public ListenableFuture> makeToast(final MakeToastInput input) { - LOG.info("makeToast: " + input); + LOG.info("makeToast: {}", input); final SettableFuture> futureResult = SettableFuture.create(); @@ -322,7 +322,7 @@ public class OpendaylightToaster extends AbstractMXBean */ @Override public ListenableFuture> restockToaster(final RestockToasterInput input) { - LOG.info("restockToaster: " + input); + LOG.info("restockToaster: {}", input); amountOfBreadInStock.set(input.getAmountOfBreadToStock()); -- 2.36.6