Program: 171101
Project: 171101
Buggy source:
@Override public void applyPatch(TypeDefPatch patch) throws AtlasBaseException {
  String typeName=patch.getTypeName();
  if (!typeRegistry.isRegisteredType(typeName)) {
    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);
      for (      AtlasAttributeDef attributeDef : patch.getAttributeDefs()) {
        updatedDef.addAttribute(attributeDef);
      }
      updatedDef.setTypeVersion(patch.getUpdateToVersion());
      typeDefStore.updateEntityDefByName(typeName,updatedDef);
    }
 else     if (typeDef.getClass().equals(AtlasClassificationDef.class)) {
      AtlasClassificationDef updatedDef=new AtlasClassificationDef((AtlasClassificationDef)typeDef);
      for (      AtlasAttributeDef attributeDef : patch.getAttributeDefs()) {
        updatedDef.addAttribute(attributeDef);
      }
      updatedDef.setTypeVersion(patch.getUpdateToVersion());
      typeDefStore.updateClassificationDefByName(typeName,updatedDef);
    }
 else     if (typeDef.getClass().equals(AtlasStructDef.class)) {
      AtlasStructDef updatedDef=new AtlasStructDef((AtlasStructDef)typeDef);
      for (      AtlasAttributeDef attributeDef : patch.getAttributeDefs()) {
        updatedDef.addAttribute(attributeDef);
      }
      updatedDef.setTypeVersion(patch.getUpdateToVersion());
      typeDefStore.updateStructDefByName(typeName,updatedDef);
    }
 else {
      throw new AtlasBaseException(AtlasErrorCode.PATCH_NOT_APPLICABLE_FOR_TYPE,patch.getAction(),typeDef.getClass().getSimpleName());
    }
  }
 else {
    LOG.info("String_Node_Str",patch.getTypeName(),patch.getApplyToVersion(),patch.getUpdateToVersion());
  }
}

Fixed version (ground truth):
@Override public void applyPatch(TypeDefPatch patch) throws AtlasBaseException {
  String typeName=patch.getTypeName();
  AtlasBaseTypeDef typeDef=typeRegistry.getTypeDefByName(typeName);
  if (typeDef == null) {
    throw new AtlasBaseException(AtlasErrorCode.PATCH_FOR_UNKNOWN_TYPE,patch.getAction(),typeName);
  }
  if (isPatchApplicable(patch,typeDef)) {
    if (typeDef.getClass().equals(AtlasEntityDef.class)) {
      AtlasEntityDef updatedDef=new AtlasEntityDef((AtlasEntityDef)typeDef);
      for (      AtlasAttributeDef attributeDef : patch.getAttributeDefs()) {
        updatedDef.addAttribute(attributeDef);
      }
      updatedDef.setTypeVersion(patch.getUpdateToVersion());
      typeDefStore.updateEntityDefByName(typeName,updatedDef);
    }
 else     if (typeDef.getClass().equals(AtlasClassificationDef.class)) {
      AtlasClassificationDef updatedDef=new AtlasClassificationDef((AtlasClassificationDef)typeDef);
      for (      AtlasAttributeDef attributeDef : patch.getAttributeDefs()) {
        updatedDef.addAttribute(attributeDef);
      }
      updatedDef.setTypeVersion(patch.getUpdateToVersion());
      typeDefStore.updateClassificationDefByName(typeName,updatedDef);
    }
 else     if (typeDef.getClass().equals(AtlasStructDef.class)) {
      AtlasStructDef updatedDef=new AtlasStructDef((AtlasStructDef)typeDef);
      for (      AtlasAttributeDef attributeDef : patch.getAttributeDefs()) {
        updatedDef.addAttribute(attributeDef);
      }
      updatedDef.setTypeVersion(patch.getUpdateToVersion());
      typeDefStore.updateStructDefByName(typeName,updatedDef);
    }
 else {
      throw new AtlasBaseException(AtlasErrorCode.PATCH_NOT_APPLICABLE_FOR_TYPE,patch.getAction(),typeDef.getClass().getSimpleName());
    }
  }
 else {
    LOG.info("String_Node_Str",patch.getTypeName(),patch.getApplyToVersion(),patch.getUpdateToVersion());
  }
}