Commit 2119666f by Madhan Neethiraj

ATLAS-1285: fix for issues flagged by Coverity scan

parent 71714d20
...@@ -315,14 +315,13 @@ public class AtlasTypeDefStoreInitializer { ...@@ -315,14 +315,13 @@ public class AtlasTypeDefStoreInitializer {
@Override @Override
public void applyPatch(TypeDefPatch patch) throws AtlasBaseException { public void applyPatch(TypeDefPatch patch) throws AtlasBaseException {
String typeName = patch.getTypeName(); 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); throw new AtlasBaseException(AtlasErrorCode.PATCH_FOR_UNKNOWN_TYPE, patch.getAction(), typeName);
} }
AtlasBaseTypeDef typeDef = typeRegistry.getTypeDefByName(typeName);
if (isPatchApplicable(patch, typeDef)) { if (isPatchApplicable(patch, typeDef)) {
if (typeDef.getClass().equals(AtlasEntityDef.class)) { if (typeDef.getClass().equals(AtlasEntityDef.class)) {
AtlasEntityDef updatedDef = new AtlasEntityDef((AtlasEntityDef)typeDef); AtlasEntityDef updatedDef = new AtlasEntityDef((AtlasEntityDef)typeDef);
......
...@@ -52,6 +52,7 @@ import java.util.List; ...@@ -52,6 +52,7 @@ import java.util.List;
import static org.apache.atlas.typesystem.types.utils.TypesUtil.createOptionalAttrDef; import static org.apache.atlas.typesystem.types.utils.TypesUtil.createOptionalAttrDef;
import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.fail; import static org.testng.Assert.fail;
/** /**
...@@ -134,8 +135,10 @@ public class TypesJerseyResourceIT extends BaseResourceIT { ...@@ -134,8 +135,10 @@ public class TypesJerseyResourceIT extends BaseResourceIT {
assertEquals(typesUpdated.size(), 1); assertEquals(typesUpdated.size(), 1);
Assert.assertTrue(typesUpdated.contains(typeDefinition.typeName)); Assert.assertTrue(typesUpdated.contains(typeDefinition.typeName));
HierarchicalTypeDefinition<ClassType> TypesDef updatedTypeDef = serviceClient.getType(typeDefinition.typeName);
updatedType = serviceClient.getType(typeDefinition.typeName).classTypesAsJavaList().get(0); assertNotNull(updatedTypeDef);
HierarchicalTypeDefinition<ClassType> updatedType = updatedTypeDef.classTypesAsJavaList().get(0);
assertEquals(updatedType.attributeDefinitions.length, 2); 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