Commit 2119666f by Madhan Neethiraj

ATLAS-1285: fix for issues flagged by Coverity scan

parent 71714d20
......@@ -316,13 +316,12 @@ public class AtlasTypeDefStoreInitializer {
@Override
public void applyPatch(TypeDefPatch patch) throws AtlasBaseException {
String typeName = patch.getTypeName();
AtlasBaseTypeDef typeDef = typeRegistry.getTypeDefByName(typeName);
if (!typeRegistry.isRegisteredType(typeName)) {
if (typeDef == null) {
throw new AtlasBaseException(AtlasErrorCode.PATCH_FOR_UNKNOWN_TYPE, patch.getAction(), typeName);
}
AtlasBaseTypeDef typeDef = typeRegistry.getTypeDefByName(typeName);
if (isPatchApplicable(patch, typeDef)) {
if (typeDef.getClass().equals(AtlasEntityDef.class)) {
AtlasEntityDef updatedDef = new AtlasEntityDef((AtlasEntityDef)typeDef);
......
......@@ -52,6 +52,7 @@ import java.util.List;
import static org.apache.atlas.typesystem.types.utils.TypesUtil.createOptionalAttrDef;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.fail;
/**
......@@ -134,8 +135,10 @@ public class TypesJerseyResourceIT extends BaseResourceIT {
assertEquals(typesUpdated.size(), 1);
Assert.assertTrue(typesUpdated.contains(typeDefinition.typeName));
HierarchicalTypeDefinition<ClassType>
updatedType = serviceClient.getType(typeDefinition.typeName).classTypesAsJavaList().get(0);
TypesDef updatedTypeDef = serviceClient.getType(typeDefinition.typeName);
assertNotNull(updatedTypeDef);
HierarchicalTypeDefinition<ClassType> updatedType = updatedTypeDef.classTypesAsJavaList().get(0);
assertEquals(updatedType.attributeDefinitions.length, 2);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment