AttributeServlet- Add null test before using nullable values
[sdc.git] / catalog-be / src / main / java / org / openecomp / sdc / be / servlets / AttributeServlet.java
index 6ea2ab1..4056d60 100644 (file)
@@ -115,6 +115,10 @@ public class AttributeServlet extends AbstractValidationsServlet {
         try {
             final Wrapper<ResponseFormat> errorWrapper = new Wrapper<>();
             AttributeDefinition attributeDataDefinition = convertJsonToObject(data, errorWrapper);
+            if (attributeDataDefinition == null) {
+                log.error("Unexpected null value for `attributeDataDefinition`");
+                return buildErrorResponse(errorWrapper.getInnerElement());
+            }
             if (errorWrapper.isEmpty()) {
                 AttributeBusinessLogic businessLogic = getClassFromWebAppContext(context, () -> AttributeBusinessLogic.class);
                 Either<AttributeDefinition, ResponseFormat> createAttribute = businessLogic
@@ -175,6 +179,10 @@ public class AttributeServlet extends AbstractValidationsServlet {
         try {
             final Wrapper<ResponseFormat> errorWrapper = new Wrapper<>();
             AttributeDefinition attributeDataDefinition = convertJsonToObject(data, errorWrapper);
+            if (attributeDataDefinition == null) {
+                log.error("Unexpected null value for `attributeDataDefinition`");
+                return buildErrorResponse(errorWrapper.getInnerElement());
+            }
             if (errorWrapper.isEmpty()) {
                 AttributeBusinessLogic businessLogic = getClassFromWebAppContext(context, () -> AttributeBusinessLogic.class);
                 Either<AttributeDefinition, ResponseFormat> eitherUpdateAttribute = businessLogic