diff options
author | Jim Hahn <jrh3@att.com> | 2021-05-07 18:07:09 -0400 |
---|---|---|
committer | Jim Hahn <jrh3@att.com> | 2021-05-07 18:13:22 -0400 |
commit | 71a2c192c13200c5f864bca610e1ba6cf99e8e82 (patch) | |
tree | ca4b6f8cc12a00b494b3337215bac6e2eca9a8e0 /models-interactions/model-actors/actorServiceProvider/src | |
parent | da708d64dc27f36ed5da733fca14ebfb4cc2832b (diff) |
Fix sonars in policy-models actors
Fixed:
- use "var"
- don't throw generic Exception
Issue-ID: POLICY-3094
Change-Id: I020addb9511fd665b5fed48e7d40719e27039224
Signed-off-by: Jim Hahn <jrh3@att.com>
Diffstat (limited to 'models-interactions/model-actors/actorServiceProvider/src')
10 files changed, 25 insertions, 29 deletions
diff --git a/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/ActorService.java b/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/ActorService.java index 4347c1d10..5cd4c8410 100644 --- a/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/ActorService.java +++ b/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/ActorService.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ActorService * ================================================================================ - * Copyright (C) 2017-2018, 2020 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017-2018, 2020-2021 AT&T Intellectual Property. All rights reserved. * Modifications Copyright (C) 2019 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -89,7 +89,7 @@ public class ActorService extends StartConfigPartial<Map<String, Object>> { } actors.sort((actor1, actor2) -> { - int cmp = Integer.compare(actor1.getSequenceNumber(), actor2.getSequenceNumber()); + var cmp = Integer.compare(actor1.getSequenceNumber(), actor2.getSequenceNumber()); if (cmp != 0) { return cmp; } @@ -108,7 +108,7 @@ public class ActorService extends StartConfigPartial<Map<String, Object>> { * @throws IllegalArgumentException if no actor by the given name exists */ public Actor getActor(String name) { - Actor actor = name2actor.get(name); + var actor = name2actor.get(name); if (actor == null) { throw new IllegalArgumentException("unknown actor " + name); } diff --git a/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/DelayedIdentString.java b/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/DelayedIdentString.java index b7a9a53ad..dc105d903 100644 --- a/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/DelayedIdentString.java +++ b/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/DelayedIdentString.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP * ================================================================================ - * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -45,7 +45,7 @@ public class DelayedIdentString { return NULL_STRING; } - String ident = objectToString(); + var ident = objectToString(); if (ident == null) { return NULL_STRING; } diff --git a/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/OperationFinalResult.java b/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/OperationFinalResult.java index 67d25f2a9..f9f3a1038 100644 --- a/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/OperationFinalResult.java +++ b/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/OperationFinalResult.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * models * ================================================================================ - * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -96,7 +96,7 @@ public enum OperationFinalResult { * @return true if a result */ public static boolean isResult(String result, OperationFinalResult finalResult) { - OperationFinalResult toResult = OperationFinalResult.toResult(result); + var toResult = OperationFinalResult.toResult(result); if (toResult == null) { return false; } diff --git a/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/OperationOutcome.java b/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/OperationOutcome.java index f5947e77d..758f49238 100644 --- a/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/OperationOutcome.java +++ b/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/OperationOutcome.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP * ================================================================================ - * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -69,7 +69,7 @@ public class OperationOutcome { * @return ControlLoopOperation */ public ControlLoopOperation toControlLoopOperation() { - ControlLoopOperation clo = new ControlLoopOperation(); + var clo = new ControlLoopOperation(); clo.setActor(actor); clo.setOperation(operation); diff --git a/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/ActorImpl.java b/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/ActorImpl.java index 336860ecb..36e5268af 100644 --- a/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/ActorImpl.java +++ b/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/ActorImpl.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP * ================================================================================ - * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -95,7 +95,7 @@ public class ActorImpl extends StartConfigPartial<Map<String, Object>> implement @Override public Operator getOperator(String name) { - Operator operator = name2operator.get(name); + var operator = name2operator.get(name); if (operator == null) { throw new IllegalArgumentException("unknown operator " + getName() + "." + name); } diff --git a/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/BidirectionalTopicOperation.java b/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/BidirectionalTopicOperation.java index b0ad38eff..c4d5cca33 100644 --- a/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/BidirectionalTopicOperation.java +++ b/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/BidirectionalTopicOperation.java @@ -22,7 +22,6 @@ package org.onap.policy.controlloop.actorserviceprovider.impl; import java.util.List; import java.util.concurrent.CompletableFuture; -import java.util.concurrent.Executor; import java.util.function.BiConsumer; import lombok.Getter; import org.onap.policy.common.endpoints.utils.NetLoggerUtil.EventType; @@ -106,11 +105,11 @@ public abstract class BidirectionalTopicOperation<Q, S> extends OperationPartial @Override protected CompletableFuture<OperationOutcome> startOperationAsync(int attempt, OperationOutcome outcome) { - final Q request = makeRequest(attempt); + final var request = makeRequest(attempt); final List<String> expectedKeyValues = getExpectedKeyValues(attempt, request); final PipelineControllerFuture<OperationOutcome> controller = new PipelineControllerFuture<>(); - final Executor executor = params.getExecutor(); + final var executor = params.getExecutor(); // register a listener BEFORE publishing diff --git a/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/HttpOperation.java b/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/HttpOperation.java index a4b48d432..4812e7739 100644 --- a/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/HttpOperation.java +++ b/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/HttpOperation.java @@ -24,7 +24,6 @@ import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.concurrent.CompletableFuture; -import java.util.concurrent.Executor; import java.util.concurrent.Future; import java.util.concurrent.TimeUnit; import java.util.function.Function; @@ -182,7 +181,7 @@ public abstract class HttpOperation<T> extends OperationPartial { final PipelineControllerFuture<OperationOutcome> controller = new PipelineControllerFuture<>(); final CompletableFuture<Response> future = new CompletableFuture<>(); - final Executor executor = params.getExecutor(); + final var executor = params.getExecutor(); // arrange for the callback to complete "future" InvocationCallback<Response> callback = new InvocationCallback<>() { diff --git a/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/OperationPartial.java b/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/OperationPartial.java index 7ad0cd82e..5fbf7d2df 100644 --- a/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/OperationPartial.java +++ b/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/OperationPartial.java @@ -225,9 +225,9 @@ public abstract class OperationPartial implements Operation { logger.info("{}: start operation attempt {} for {}", getFullName(), attempt, params.getRequestId()); - final Executor executor = params.getExecutor(); - final OperationOutcome outcome = makeOutcome(); - final CallbackManager callbacks = new CallbackManager(); + final var executor = params.getExecutor(); + final var outcome = makeOutcome(); + final var callbacks = new CallbackManager(); // this operation attempt gets its own controller final PipelineControllerFuture<OperationOutcome> controller = new PipelineControllerFuture<>(); @@ -594,14 +594,13 @@ public abstract class OperationPartial implements Operation { * @return an array of futures, possibly zero-length. If the array is of size one, * then that one item should be returned instead of the controller */ + @SuppressWarnings("unchecked") private CompletableFuture<OperationOutcome>[] attachFutures(PipelineControllerFuture<OperationOutcome> controller, List<Supplier<CompletableFuture<OperationOutcome>>> futureMakers, UnaryOperator<CompletableFuture<OperationOutcome>> adorn) { if (futureMakers.isEmpty()) { - @SuppressWarnings("unchecked") - CompletableFuture<OperationOutcome>[] result = new CompletableFuture[0]; - return result; + return new CompletableFuture[0]; } // the last, unadorned future that is created @@ -631,8 +630,7 @@ public abstract class OperationPartial implements Operation { } } - @SuppressWarnings("unchecked") - CompletableFuture<OperationOutcome>[] result = new CompletableFuture[futures.size()]; + var result = new CompletableFuture[futures.size()]; if (result.length == 1) { // special case - return the unadorned future @@ -747,7 +745,7 @@ public abstract class OperationPartial implements Operation { * executing */ final PipelineControllerFuture<OperationOutcome> controller = new PipelineControllerFuture<>(); - final Executor executor = params.getExecutor(); + final var executor = params.getExecutor(); // @formatter:off controller.wrap(nextTask) @@ -830,7 +828,7 @@ public abstract class OperationPartial implements Operation { outcome.setEnd(null); // pass a copy to the callback - OperationOutcome outcome2 = new OperationOutcome(outcome); + var outcome2 = new OperationOutcome(outcome); outcome2.setFinalOutcome(false); params.callbackStarted(outcome2); } diff --git a/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/OperatorPartial.java b/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/OperatorPartial.java index e75e99eaa..eacb10777 100644 --- a/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/OperatorPartial.java +++ b/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/OperatorPartial.java @@ -38,7 +38,7 @@ public abstract class OperatorPartial extends StartConfigPartial<Map<String, Obj */ @Getter private final Executor blockingExecutor = command -> { - Thread thread = new Thread(command); + var thread = new Thread(command); thread.setDaemon(true); thread.start(); }; diff --git a/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/parameters/ControlLoopOperationParams.java b/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/parameters/ControlLoopOperationParams.java index f28777097..22dfc28bc 100644 --- a/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/parameters/ControlLoopOperationParams.java +++ b/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/parameters/ControlLoopOperationParams.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP * ================================================================================ - * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -188,7 +188,7 @@ public class ControlLoopOperationParams { * @return a new operation outcome */ public OperationOutcome makeOutcome() { - OperationOutcome outcome = new OperationOutcome(); + var outcome = new OperationOutcome(); outcome.setActor(getActor()); outcome.setOperation(getOperation()); |