From 25a55717cf3d16c3bbaf0efdf197e5ccd68123da Mon Sep 17 00:00:00 2001 From: "prakash.e" Date: Fri, 5 Jan 2018 12:15:29 +0530 Subject: Exception issue *deployList is used before initialization which results in NullPointer Exception. Change-Id: I53d43d7656577368ac35db78ba27c015a2c8ac52 Issue-ID: CCSDK-170 Signed-off-by: prakash.e --- .../sli/northbound/uebclient/SdncUebCallback.java | 43 +++++++++++----------- 1 file changed, 21 insertions(+), 22 deletions(-) diff --git a/ueb-listener/src/main/java/org/onap/ccsdk/sli/northbound/uebclient/SdncUebCallback.java b/ueb-listener/src/main/java/org/onap/ccsdk/sli/northbound/uebclient/SdncUebCallback.java index b9df86ef3..35e62f88c 100644 --- a/ueb-listener/src/main/java/org/onap/ccsdk/sli/northbound/uebclient/SdncUebCallback.java +++ b/ueb-listener/src/main/java/org/onap/ccsdk/sli/northbound/uebclient/SdncUebCallback.java @@ -326,6 +326,15 @@ public class SdncUebCallback implements INotificationCallback { } } + // Deploy scheduled deployments + int numPasses = config.getMaxPasses(); + + deployList = new LinkedList[numPasses]; + + for (int i = 0 ; i < numPasses ; i++) { + deployList[i] = new LinkedList<>(); + } + LOG.debug("Scanning {} - {} for downloaded files", incomingDir.getPath(), incomingDir.toPath()); try (DirectoryStream stream = Files.newDirectoryStream(incomingDir.toPath())) { for (Path file: stream) { @@ -337,14 +346,6 @@ public class SdncUebCallback implements INotificationCallback { LOG.warn("Cannot process spool file", x); } - // Deploy scheduled deployments - int numPasses = config.getMaxPasses(); - - deployList = new LinkedList[numPasses]; - - for (int i = 0 ; i < numPasses ; i++) { - deployList[i] = new LinkedList<>(); - } for (int pass = 0 ; pass < config.getMaxPasses() ; pass++) { if (deployList[pass] != null) { @@ -854,24 +855,22 @@ public class SdncUebCallback implements INotificationCallback { } private void scheduleDeployment(SdncArtifactType type, String svcName, String resourceName, IArtifactInfo artifactInfo, String spoolFileName, File spoolFile) { - if (deployList != null) { - if (type.getPass() < deployList.length) { + if (type.getPass() < deployList.length) { - if (artifactInfo != null) { - LOG.debug("Scheduling "+artifactInfo.getArtifactName()+" version "+artifactInfo.getArtifactVersion()+" for deployment"); + if (artifactInfo != null) { + LOG.debug("Scheduling " + artifactInfo.getArtifactName() + " version " + artifactInfo.getArtifactVersion() + " for deployment"); - deployList[type.getPass()].add(new DeployableArtifact(type, svcName, resourceName, artifactInfo, spoolFile)); - } else { - SimpleDateFormat sdfDate = new SimpleDateFormat("yyyy-MM-dd_HH:mm:ss.SSS");//dd/MM/yyyy - Date now = new Date(); - String artifactVersion = sdfDate.format(now); - LOG.debug("Scheduling "+spoolFileName+" version "+artifactVersion+" for deployment"); - deployList[type.getPass()].add(new DeployableArtifact(type, svcName, resourceName, spoolFileName, - artifactVersion, spoolFile)); - } + deployList[type.getPass()].add(new org.onap.ccsdk.sli.northbound.uebclient.SdncUebCallback.DeployableArtifact(type, svcName, resourceName, artifactInfo, spoolFile)); } else { - LOG.info("Pass for type "+type.getTag()+" is "+type.getPass()+" which is not <= "+deployList.length); + SimpleDateFormat sdfDate = new SimpleDateFormat("yyyy-MM-dd_HH:mm:ss.SSS");//dd/MM/yyyy + Date now = new Date(); + String artifactVersion = sdfDate.format(now); + LOG.debug("Scheduling " + spoolFileName + " version " + artifactVersion + " for deployment"); + deployList[type.getPass()].add(new org.onap.ccsdk.sli.northbound.uebclient.SdncUebCallback.DeployableArtifact(type, svcName, resourceName, spoolFileName, + artifactVersion, spoolFile)); } + } else { + LOG.info("Pass for type " + type.getTag() + " is " + type.getPass() + " which is not <= " + deployList.length); } } -- cgit 1.2.3-korg