From fd5a6566d0e12540b4ac49b24603bae26666ab94 Mon Sep 17 00:00:00 2001 From: "arkadiusz.adamski" Date: Wed, 24 Mar 2021 16:24:22 +0000 Subject: Fix sonar issues - reduce methods Cognitive Complexity from 19 to the 15 allowed in CommandLineParser - iteration replaced with bulk 'Collection.addAll' call - remove redundant initializers - replace try with try-with-resources Issue-ID: POLICY-3093 Signed-off-by: arkadiusz.adamski Change-Id: Ia727b3145ef8f63bcfc07723191c85e1ec8c923c --- .../consumer/HeaderDelimitedTextBlockReader.java | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'services/services-engine/src') diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/filecarrierplugin/consumer/HeaderDelimitedTextBlockReader.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/filecarrierplugin/consumer/HeaderDelimitedTextBlockReader.java index 5531d9704..67b7cb871 100644 --- a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/filecarrierplugin/consumer/HeaderDelimitedTextBlockReader.java +++ b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/filecarrierplugin/consumer/HeaderDelimitedTextBlockReader.java @@ -1,19 +1,20 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2016-2018 Ericsson. All rights reserved. + * Modifications Copyright (C) 2020-2021 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * + * * SPDX-License-Identifier: Apache-2.0 * ============LICENSE_END========================================================= */ @@ -50,7 +51,7 @@ public class HeaderDelimitedTextBlockReader implements TextBlockReader, Runnable // Indicates that text block processing starts at the first block of text private final boolean delimiterAtStart; - private boolean blockEndTokenUsed = false; + private boolean blockEndTokenUsed; // The thread used to read the text from the stream private Thread textConsumputionThread; @@ -170,9 +171,7 @@ public class HeaderDelimitedTextBlockReader implements TextBlockReader, Runnable */ @Override public void run() { - final BufferedReader textReader = new BufferedReader(new InputStreamReader(inputStream)); - - try { + try (BufferedReader textReader = new BufferedReader(new InputStreamReader(inputStream))) { // Read the input line by line until we see end of file on the stream String line; while ((line = textReader.readLine()) != null) { -- cgit 1.2.3-korg