From 1e538efce498a934d52e074f095838229b9cd1af Mon Sep 17 00:00:00 2001 From: Jegadeesh Babu Date: Thu, 21 Mar 2019 21:52:29 +0530 Subject: Modified code to avoid null pointer exception Sonar fix Issue-ID: APPC-1550 Change-Id: I6c6afcf13e33f06d70883a588574ed83a9e2dfdc Signed-off-by: Jegadeesh Babu --- .../java/org/onap/appc/design/dbervices/DesignDBService.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'appc-inbound/appc-design-services') diff --git a/appc-inbound/appc-design-services/provider/src/main/java/org/onap/appc/design/dbervices/DesignDBService.java b/appc-inbound/appc-design-services/provider/src/main/java/org/onap/appc/design/dbervices/DesignDBService.java index 4e6375b91..2353e6b0c 100644 --- a/appc-inbound/appc-design-services/provider/src/main/java/org/onap/appc/design/dbervices/DesignDBService.java +++ b/appc-inbound/appc-design-services/provider/src/main/java/org/onap/appc/design/dbervices/DesignDBService.java @@ -7,6 +7,7 @@ * Copyright (C) 2017 Amdocs * ================================================================================ * Modifications (C) 2019 Ericsson + * Modifications (C) 2019 IBM * ============================================================================= * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -185,10 +186,12 @@ public class DesignDBService { throw new DBException( "Error occured while validating/Saving the artifact to SDC_ARTIFACTS or getting SDC_ARTIFACTS_ID ."); JsonNode json = payloadObject.get(DesignServiceConstants.USER_ID); - if (json == null || json.asText().trim().isEmpty()) { - log.info("UserId in Admin Aritfact is null or blank, User Id : " + json.asText()); - throw new DBException("User Id is null or blank"); - } + if (json == null) { + throw new DBException("User Id is null"); + } else if (json.asText().trim().isEmpty()) { + log.info("UserId in Admin Aritfact is blank, User Id : " + json.asText()); + throw new DBException("User Id is blank"); + } int sdcReferenceId = 0; createArtifactTrackingRecord(payload, requestId, sdcArtifactId, sdcReferenceId); -- cgit 1.2.3-korg