Program: 115479
Project: 115479
Buggy source:
/** 
 * Creates the cartridge group definition.
 * @param cartridgeGroupBean the cartridge group definition
 * @return 201 if group added successfully
 * @throws RestAPIException the rest api exception
 */
@POST @Path("String_Node_Str") @Produces("String_Node_Str") @Consumes("String_Node_Str") @AuthorizationAction("String_Node_Str") public Response addCartridgeGroup(CartridgeGroupBean cartridgeGroupBean) throws RestAPIException {
  PrivilegedCarbonContext carbonContext=PrivilegedCarbonContext.getThreadLocalCarbonContext();
  String cartrideGroupUuid=UUID.randomUUID().toString();
  int tenantId=carbonContext.getTenantId();
  CartridgeGroupBean groupBean=null;
  groupBean=StratosApiV41Utils.getServiceGroupDefinition(cartridgeGroupBean.getName(),carbonContext.getTenantId());
  if (groupBean != null) {
    String msg=String.format("String_Node_Str",cartridgeGroupBean.getName());
    log.warn(msg);
    return Response.status(Response.Status.CONFLICT).entity(new ResponseMessageBean(ResponseMessageBean.ERROR,msg)).build();
  }
  try {
    StratosApiV41Utils.addCartridgeGroup(cartridgeGroupBean,cartrideGroupUuid,tenantId);
    URI url=uriInfo.getAbsolutePathBuilder().path(cartridgeGroupBean.getName()).build();
    return Response.created(url).entity(new ResponseMessageBean(ResponseMessageBean.SUCCESS,String.format("String_Node_Str",cartridgeGroupBean.getName()))).build();
  }
 catch (  InvalidCartridgeGroupDefinitionException e) {
    return Response.status(Response.Status.BAD_REQUEST).entity(new ResponseMessageBean(ResponseMessageBean.ERROR,e.getMessage())).build();
  }
catch (  ServiceGroupDefinitionException e) {
    return Response.status(Response.Status.BAD_REQUEST).entity(new ResponseMessageBean(ResponseMessageBean.ERROR,e.getMessage())).build();
  }
catch (  AutoscalerServiceInvalidServiceGroupExceptionException e) {
    return Response.status(Response.Status.BAD_REQUEST).entity(new ResponseMessageBean(ResponseMessageBean.ERROR,e.getFaultMessage().getInvalidServiceGroupException().getMessage())).build();
  }
catch (  CloudControllerServiceCartridgeNotFoundExceptionException e) {
    return Response.status(Response.Status.BAD_REQUEST).entity(new ResponseMessageBean(ResponseMessageBean.ERROR,e.getFaultMessage().getCartridgeNotFoundException().getMessage())).build();
  }
}

Fixed version (ground truth):
/** 
 * Creates the cartridge group definition.
 * @param cartridgeGroupBean the cartridge group definition
 * @return 201 if group added successfully
 * @throws RestAPIException the rest api exception
 */
@POST @Path("String_Node_Str") @Produces("String_Node_Str") @Consumes("String_Node_Str") @AuthorizationAction("String_Node_Str") public Response addCartridgeGroup(CartridgeGroupBean cartridgeGroupBean) throws RestAPIException {
  PrivilegedCarbonContext carbonContext=PrivilegedCarbonContext.getThreadLocalCarbonContext();
  String cartrideGroupUuid=UUID.randomUUID().toString();
  int tenantId=carbonContext.getTenantId();
  CartridgeGroupBean groupBean;
  groupBean=StratosApiV41Utils.getOuterServiceGroupDefinition(cartridgeGroupBean.getName(),carbonContext.getTenantId());
  if (groupBean != null) {
    String msg=String.format("String_Node_Str",cartridgeGroupBean.getName());
    log.warn(msg);
    return Response.status(Response.Status.CONFLICT).entity(new ResponseMessageBean(ResponseMessageBean.ERROR,msg)).build();
  }
  try {
    StratosApiV41Utils.addCartridgeGroup(cartridgeGroupBean,cartrideGroupUuid,tenantId);
    URI url=uriInfo.getAbsolutePathBuilder().path(cartridgeGroupBean.getName()).build();
    return Response.created(url).entity(new ResponseMessageBean(ResponseMessageBean.SUCCESS,String.format("String_Node_Str",cartridgeGroupBean.getName()))).build();
  }
 catch (  InvalidCartridgeGroupDefinitionException e) {
    return Response.status(Response.Status.BAD_REQUEST).entity(new ResponseMessageBean(ResponseMessageBean.ERROR,e.getMessage())).build();
  }
catch (  ServiceGroupDefinitionException e) {
    return Response.status(Response.Status.BAD_REQUEST).entity(new ResponseMessageBean(ResponseMessageBean.ERROR,e.getMessage())).build();
  }
catch (  AutoscalerServiceInvalidServiceGroupExceptionException e) {
    return Response.status(Response.Status.BAD_REQUEST).entity(new ResponseMessageBean(ResponseMessageBean.ERROR,e.getFaultMessage().getInvalidServiceGroupException().getMessage())).build();
  }
catch (  CloudControllerServiceCartridgeNotFoundExceptionException e) {
    return Response.status(Response.Status.BAD_REQUEST).entity(new ResponseMessageBean(ResponseMessageBean.ERROR,e.getFaultMessage().getCartridgeNotFoundException().getMessage())).build();
  }
}