diff options
author | mkidd <michael.kidd@est.tech> | 2021-03-29 10:16:18 +0200 |
---|---|---|
committer | mkidd <michael.kidd@est.tech> | 2021-03-29 10:47:40 +0200 |
commit | 098e9903bfbf2861ac932f32b24a18ee370d7cc3 (patch) | |
tree | b63e75d04a8358b9a9b281f0f1bb11fff787e4e9 /gui-editors/gui-editor-apex/src/main/java | |
parent | aabae2a75c606a8f44fd5e0b38d840bf8cd767dc (diff) |
Fix sonarqube code Bug
ApexEditorParameters has a URI that sonar does not like, hard coding the leading forward slash removes the complaint
ApexEditorMain was receiving args and a print stream in the form of System.err and then System.out, both of these were null values, while Sonar sees System.out or err as a bug as it should be a logger, simply passing null in its place is not an issue to sonar
BeanBase.java Removed an if statement that always asserted to be true, as it is inside an if statement that confirmed that condition.
removed an accessibility change as sonar sees this as a violation
Issue-ID: POLICY-3095
Signed-off-by: mkidd <michael.kidd@est.tech>
Change-Id: I1bbdfe9cc6db085195e95da3dbfbc8b29d9a5ff5
Signed-off-by: mkidd <michael.kidd@est.tech>
Diffstat (limited to 'gui-editors/gui-editor-apex/src/main/java')
3 files changed, 8 insertions, 10 deletions
diff --git a/gui-editors/gui-editor-apex/src/main/java/org/onap/policy/gui/editors/apex/rest/ApexEditorMain.java b/gui-editors/gui-editor-apex/src/main/java/org/onap/policy/gui/editors/apex/rest/ApexEditorMain.java index 53d94c8..1d8f1d3 100644 --- a/gui-editors/gui-editor-apex/src/main/java/org/onap/policy/gui/editors/apex/rest/ApexEditorMain.java +++ b/gui-editors/gui-editor-apex/src/main/java/org/onap/policy/gui/editors/apex/rest/ApexEditorMain.java @@ -1,7 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2016-2018 Ericsson. All rights reserved. - * Modifications Copyright (C) 2019-2020 Nordix Foundation. + * Modifications Copyright (C) 2019-2021 Nordix Foundation. * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -212,7 +212,7 @@ public class ApexEditorMain { */ public static void main(final String[] args) { try { - final ApexEditorMain editorMain = new ApexEditorMain(args, System.out); + final ApexEditorMain editorMain = new ApexEditorMain(args, null); editorMain.init(); } catch (final Exception e) { LOGGER.error("start failed", e); diff --git a/gui-editors/gui-editor-apex/src/main/java/org/onap/policy/gui/editors/apex/rest/ApexEditorParameters.java b/gui-editors/gui-editor-apex/src/main/java/org/onap/policy/gui/editors/apex/rest/ApexEditorParameters.java index e89e69f..7eb0195 100644 --- a/gui-editors/gui-editor-apex/src/main/java/org/onap/policy/gui/editors/apex/rest/ApexEditorParameters.java +++ b/gui-editors/gui-editor-apex/src/main/java/org/onap/policy/gui/editors/apex/rest/ApexEditorParameters.java @@ -1,7 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2016-2018 Ericsson. All rights reserved. - * Modifications Copyright (C) 2020 Nordix Foundation. + * 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. @@ -50,7 +50,7 @@ public class ApexEditorParameters { private static final String DEFAULT_SERVER_URI_PREFIX = "http://"; /** The server listens on localhost by default. */ public static final String DEFAULT_SERVER_URI_ROOT = "localhost"; - private static final String DEFAULT_REST_PATH = "/apexservices/"; + private static final String DEFAULT_REST_PATH = "apexservices/"; private static final String DEFAULT_STATIC_PATH = "/"; // Constants for port checks @@ -90,7 +90,7 @@ public class ApexEditorParameters { * @return the base URI */ public URI getBaseUri() { - return URI.create(DEFAULT_SERVER_URI_PREFIX + listenAddress + ':' + restPort + DEFAULT_REST_PATH); + return URI.create(DEFAULT_SERVER_URI_PREFIX + listenAddress + ':' + restPort + "/" + DEFAULT_REST_PATH); } /** diff --git a/gui-editors/gui-editor-apex/src/main/java/org/onap/policy/gui/editors/apex/rest/handling/bean/BeanBase.java b/gui-editors/gui-editor-apex/src/main/java/org/onap/policy/gui/editors/apex/rest/handling/bean/BeanBase.java index 261cbae..dbc5ae2 100644 --- a/gui-editors/gui-editor-apex/src/main/java/org/onap/policy/gui/editors/apex/rest/handling/bean/BeanBase.java +++ b/gui-editors/gui-editor-apex/src/main/java/org/onap/policy/gui/editors/apex/rest/handling/bean/BeanBase.java @@ -1,7 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2016-2018 Ericsson. All rights reserved. - * Modifications Copyright (C) 2020 Nordix Foundation. + * 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. @@ -54,10 +54,8 @@ public abstract class BeanBase { if (field != null) { try { final Field f = this.getClass().getDeclaredField(field); - if (f != null) { - f.setAccessible(true); - return (String) (f.get(this)); - } + f.trySetAccessible(); + return (String) (f.get(this)); } catch (final Exception e) { throw new IllegalArgumentException(PROBLEM_RETRIEVING_FIELD_PREFIX + field + JSON_BEAN_SUFFIX + this, e); |