diff options
author | shashikanth <shashikanth.vh@huawei.com> | 2017-09-18 14:44:59 +0530 |
---|---|---|
committer | Skip Wonnell <skip@att.com> | 2017-09-20 13:03:54 +0000 |
commit | b59ab6b65a4f81464a970e579107d0828f78aadc (patch) | |
tree | babbca2a1ff06f5ca46424b5448e7f6cd24038d1 /appc-config/appc-config-adaptor/provider/src/main/java | |
parent | b6e1a7e77f59259c0f0a200ebff22ad9fc7940b3 (diff) |
Fix Blocker/Critical sonar issues
Fix Blocker/Critical sonar issues in appc module
https://sonar.onap.org/issues/search#issues=AV36Pm5i89V-MRZU59OH
Fixed NullPointerException might be thrown as 'data' is nullable here
Issue-Id: APPC-186
Change-Id: I65ee1745f5fd5a7f7ac3365704943b25a9341e8a
Signed-off-by: shashikanth.vh <shashikanth.vh@huawei.com>
Diffstat (limited to 'appc-config/appc-config-adaptor/provider/src/main/java')
-rw-r--r-- | appc-config/appc-config-adaptor/provider/src/main/java/org/openecomp/appc/ccadaptor/ConfigComponentAdaptor.java | 38 |
1 files changed, 21 insertions, 17 deletions
diff --git a/appc-config/appc-config-adaptor/provider/src/main/java/org/openecomp/appc/ccadaptor/ConfigComponentAdaptor.java b/appc-config/appc-config-adaptor/provider/src/main/java/org/openecomp/appc/ccadaptor/ConfigComponentAdaptor.java index 02644ac92..4e59dd345 100644 --- a/appc-config/appc-config-adaptor/provider/src/main/java/org/openecomp/appc/ccadaptor/ConfigComponentAdaptor.java +++ b/appc-config/appc-config-adaptor/provider/src/main/java/org/openecomp/appc/ccadaptor/ConfigComponentAdaptor.java @@ -165,8 +165,6 @@ public class ConfigComponentAdaptor implements SvcLogicAdaptor password = EncryptionTool.getInstance().decrypt(password); String fullPathFileName = parameters.get("fullPathFileName"); String data = null; - if (key.equals("put")) - data = parameters.get("data"); SshJcraftWrapper sshJcraftWrapper = new SshJcraftWrapper(); log.debug("SCP: SshJcraftWrapper has been instantiated"); @@ -175,21 +173,27 @@ public class ConfigComponentAdaptor implements SvcLogicAdaptor { if (key.equals("put")) { - debugLog.printRTAriDebug(fnName, "Command is for put: Length of data is: " + data.length()); - InputStream is = new ByteArrayInputStream(data.getBytes()); - log.debug("SCP: Doing a put: fullPathFileName=" + fullPathFileName); - debugLog.printRTAriDebug(fnName, "SCP: Doing a put: fullPathFileName=" + fullPathFileName); - sshJcraftWrapper.put(is, fullPathFileName, host, loginId, password); - try - { - debugLog.printRTAriDebug(fnName, "Sleeping for 180 seconds...."); - Thread.sleep(1000 * 180); - debugLog.printRTAriDebug(fnName, "Woke up...."); - } - catch (java.lang.InterruptedException ee) - { - boolean ignore = true; - } + data = parameters.get("data"); + if (data != null) { + debugLog.printRTAriDebug(fnName, "Command is for put: Length of data is: " + data.length()); + InputStream is = new ByteArrayInputStream(data.getBytes()); + log.debug("SCP: Doing a put: fullPathFileName=" + fullPathFileName); + debugLog.printRTAriDebug(fnName, "SCP: Doing a put: fullPathFileName=" + fullPathFileName); + sshJcraftWrapper.put(is, fullPathFileName, host, loginId, password); + try + { + debugLog.printRTAriDebug(fnName, "Sleeping for 180 seconds...."); + Thread.sleep(1000 * 180); + debugLog.printRTAriDebug(fnName, "Woke up...."); + } + catch (java.lang.InterruptedException ee) + { + boolean ignore = true; + } + } else { + r.code = HttpURLConnection.HTTP_INTERNAL_ERROR; + log.debug(fnName + " Command is for put: data is null"); + } } else // Must be a get { |