summaryrefslogtreecommitdiffstats
path: root/aai-core
diff options
context:
space:
mode:
authorKajur, Harish (vk250x) <vk250x@att.com>2019-04-07 19:24:53 -0400
committerKajur, Harish (vk250x) <vk250x@att.com>2019-04-07 19:24:53 -0400
commit31b7af4804219e5f03faeecef55f041f48adb6d5 (patch)
treea2f82f3d2f756254e3c16f1c6b83cf6ff57becb9 /aai-core
parent08c1bd4d78a0504e7531876869a7ae0cd9c448df (diff)
Fix a potential bug in DBSerializer
where the assumption is the aai-node-type property will exist on the node types. There is a case where a vertex is in the process of being deleted and during that time the vertex will be missing some properties and during that time the GET with depth all will result in exception This is possible because of our database being an eventually consistent database Issue-ID: AAI-2330 Change-Id: I2b11c9a2ec5c3b6bffd2690a0c075962e80781cc Signed-off-by: Kajur, Harish (vk250x) <vk250x@att.com>
Diffstat (limited to 'aai-core')
-rw-r--r--aai-core/src/main/java/org/onap/aai/serialization/db/DBSerializer.java20
1 files changed, 17 insertions, 3 deletions
diff --git a/aai-core/src/main/java/org/onap/aai/serialization/db/DBSerializer.java b/aai-core/src/main/java/org/onap/aai/serialization/db/DBSerializer.java
index a23ff1f9..4c9a9b15 100644
--- a/aai-core/src/main/java/org/onap/aai/serialization/db/DBSerializer.java
+++ b/aai-core/src/main/java/org/onap/aai/serialization/db/DBSerializer.java
@@ -50,6 +50,7 @@ import org.onap.aai.introspection.exceptions.AAIUnknownObjectException;
import org.onap.aai.introspection.sideeffect.*;
import org.onap.aai.logging.ErrorLogHelper;
import org.onap.aai.logging.LogFormatTools;
+import org.onap.aai.logging.LoggingContext;
import org.onap.aai.logging.StopWatch;
import org.onap.aai.parsers.query.QueryParser;
import org.onap.aai.parsers.uri.URIParser;
@@ -89,6 +90,8 @@ public class DBSerializer {
private static final EELFLogger LOGGER = EELFManager.getInstance().getLogger(DBSerializer.class);
+ private static final String MISSING_REQUIRED_NODE_PROPERTY = "Vertex missing required aai-node-type property";
+
private final TransactionalGraphEngine engine;
private final String sourceOfTruth;
private final ModelType introspectionType;
@@ -1033,7 +1036,16 @@ public class DBSerializer {
}
List<Object> relationshipObjList = obj.getValue("relationship");
- String aNodeType = v.property("aai-node-type").value().toString();
+ VertexProperty nodeTypeProperty = v.property(AAIProperties.NODE_TYPE);
+
+ if(!nodeTypeProperty.isPresent()){
+ LoggingContext.responseDescription(MISSING_REQUIRED_NODE_PROPERTY);
+ LOGGER.warn("Not processing the vertex {} because its missing required property aai-node-type", v.id());
+ LoggingContext.remove(LoggingContext.LoggingField.RESPONSE_DESCRIPTION.toString());
+ return null;
+ }
+
+ String aNodeType = nodeTypeProperty.value().toString();
TypeAlphabetizer alphabetizer = new TypeAlphabetizer();
@@ -1053,19 +1065,21 @@ public class DBSerializer {
// from using the edge rules json and get the edge rule out of it
EdgeRuleQuery.Builder queryBuilder = new EdgeRuleQuery.Builder(aNodeType);
for (Vertex cousin : cousins) {
- VertexProperty vertexProperty = cousin.property("aai-node-type");
+ VertexProperty vertexProperty = cousin.property(AAIProperties.NODE_TYPE);
String bNodeType = null;
if(vertexProperty.isPresent()){
- bNodeType = cousin.property("aai-node-type").value().toString();
+ bNodeType = cousin.property(AAIProperties.NODE_TYPE).value().toString();
} else {
// If the vertex is missing the aai-node-type
// Then its either a bad vertex or its in the process
// of getting deleted so we should ignore these vertexes
+ LoggingContext.responseDescription(MISSING_REQUIRED_NODE_PROPERTY);
if(LOGGER.isDebugEnabled()){
LOGGER.debug("For the vertex {}, unable to retrieve the aai-node-type", v.id().toString());
} else {
LOGGER.info("Unable to retrieve the aai-node-type for vertex, for more info enable debug log");
}
+ LoggingContext.remove(LoggingContext.LoggingField.RESPONSE_DESCRIPTION.toString());
continue;
}
if (obj.getVersion().compareTo(schemaVersions.getEdgeLabelVersion()) >= 0) {