From: Robert Varga Date: Thu, 21 Jan 2021 16:08:08 +0000 (+0100) Subject: Fix modernizer warnings in sal-distributed-eos X-Git-Tag: v3.0.5~3 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=commitdiff_plain;h=df723a6e2d793bde32b63d0ca2192f5ae3c22256 Fix modernizer warnings in sal-distributed-eos There are just two violations, fix them up and enable enforcement. Change-Id: I07e38270d0b24fa5ca4a701808e2b20c0b820803 Signed-off-by: Robert Varga --- diff --git a/opendaylight/md-sal/sal-distributed-eos/pom.xml b/opendaylight/md-sal/sal-distributed-eos/pom.xml index 6811e0ec11..73e970bc34 100644 --- a/opendaylight/md-sal/sal-distributed-eos/pom.xml +++ b/opendaylight/md-sal/sal-distributed-eos/pom.xml @@ -11,11 +11,6 @@ sal-distributed-eos bundle - - - false - - org.opendaylight.mdsal diff --git a/opendaylight/md-sal/sal-distributed-eos/src/main/java/org/opendaylight/controller/cluster/entityownership/selectionstrategy/LeastLoadedCandidateSelectionStrategy.java b/opendaylight/md-sal/sal-distributed-eos/src/main/java/org/opendaylight/controller/cluster/entityownership/selectionstrategy/LeastLoadedCandidateSelectionStrategy.java index 2ef4426ddd..fc53f9545e 100644 --- a/opendaylight/md-sal/sal-distributed-eos/src/main/java/org/opendaylight/controller/cluster/entityownership/selectionstrategy/LeastLoadedCandidateSelectionStrategy.java +++ b/opendaylight/md-sal/sal-distributed-eos/src/main/java/org/opendaylight/controller/cluster/entityownership/selectionstrategy/LeastLoadedCandidateSelectionStrategy.java @@ -7,9 +7,10 @@ */ package org.opendaylight.controller.cluster.entityownership.selectionstrategy; +import static com.google.common.base.Preconditions.checkArgument; +import static java.util.Objects.requireNonNullElse; + import com.google.common.annotations.VisibleForTesting; -import com.google.common.base.MoreObjects; -import com.google.common.base.Preconditions; import com.google.common.base.Strings; import java.util.Collection; import java.util.HashMap; @@ -31,17 +32,17 @@ public class LeastLoadedCandidateSelectionStrategy extends AbstractEntityOwnerSe @Override public String newOwner(final String currentOwner, final Collection viableCandidates) { - Preconditions.checkArgument(viableCandidates.size() > 0); + checkArgument(viableCandidates.size() > 0); String leastLoadedCandidate = null; long leastLoadedCount = Long.MAX_VALUE; if (!Strings.isNullOrEmpty(currentOwner)) { - long localVal = MoreObjects.firstNonNull(localStatistics.get(currentOwner), 0L); + long localVal = requireNonNullElse(localStatistics.get(currentOwner), 0L); localStatistics.put(currentOwner, localVal - 1); } for (String candidateName : viableCandidates) { - long val = MoreObjects.firstNonNull(localStatistics.get(candidateName), 0L); + long val = requireNonNullElse(localStatistics.get(candidateName), 0L); if (val < leastLoadedCount) { leastLoadedCount = val; leastLoadedCandidate = candidateName;