From e4ec0393447f52276aa246dad29f116487c9bb28 Mon Sep 17 00:00:00 2001 From: shashikanth Date: Wed, 20 Sep 2017 12:16:52 +0530 Subject: Fix Blocker/Critical sonar issues Fix Blocker/Critical sonar issues in aai/sparky-be module https://sonar.onap.org/component_issues?id=org.openecomp.aai.sparky-be%3Asparky-be#resolved=false|severities=BLOCKER Fixed condition that it does not always evaluate to "true" Issue-Id:AAI-342 Change-Id: I7ac764c1619a834bb9c9c2bf4ce29b9bae294c0f Signed-off-by: shashikanth.vh --- .../sparky/synchronizer/ElasticSearchIndexCleaner.java | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'src/main') diff --git a/src/main/java/org/openecomp/sparky/synchronizer/ElasticSearchIndexCleaner.java b/src/main/java/org/openecomp/sparky/synchronizer/ElasticSearchIndexCleaner.java index b23764c..9ef4fe6 100644 --- a/src/main/java/org/openecomp/sparky/synchronizer/ElasticSearchIndexCleaner.java +++ b/src/main/java/org/openecomp/sparky/synchronizer/ElasticSearchIndexCleaner.java @@ -521,11 +521,6 @@ public class ElasticSearchIndexCleaner implements IndexCleaner { } JsonNode rootNode = parseElasticSearchResult(opResult.getResult()); - boolean timedOut = Boolean.parseBoolean(getFieldValue(rootNode, "timed_out")); - final String tookStr = getFieldValue(rootNode, "took"); - int tookInMs = (tookStr == null) ? 0 : Integer.parseInt(tookStr); - - JsonNode hitsNode = rootNode.get("hits"); /* * Check the result for success / failure, and enumerate all the index ids that resulted in @@ -533,6 +528,11 @@ public class ElasticSearchIndexCleaner implements IndexCleaner { */ if (rootNode != null) { + boolean timedOut = Boolean.parseBoolean(getFieldValue(rootNode, "timed_out")); + final String tookStr = getFieldValue(rootNode, "took"); + int tookInMs = (tookStr == null) ? 0 : Integer.parseInt(tookStr); + + JsonNode hitsNode = rootNode.get("hits"); if (timedOut) { LOG.info(AaiUiMsgs.COLLECT_TIME_WITH_ERROR, "Scroll Context", String.valueOf(tookInMs)); @@ -576,6 +576,9 @@ public class ElasticSearchIndexCleaner implements IndexCleaner { } } + } else { + // scroll context get failed, nothing else to do + LOG.error(AaiUiMsgs.ERROR_GENERIC, opResult.toString()); } return OperationState.OK; -- cgit 1.2.3-korg