Program: 160986
Project: 160986
Buggy source:
/** 
 * Delete an object, and also any incoming referencing objects (which must be a closed group).
 * @param sourceParam
 * @param objectTypeParam
 * @param keyParam
 */
@DELETE @Consumes({MediaType.APPLICATION_XML,MediaType.APPLICATION_JSON}) @Produces({MediaType.APPLICATION_XML,MediaType.APPLICATION_JSON}) @Path("String_Node_Str") public Response delete(@Context final HttpServletRequest request,@PathParam("String_Node_Str") final String sourceParam,@PathParam("String_Node_Str") final String objectTypeParam,@PathParam("String_Node_Str") final String keyParam,@QueryParam("String_Node_Str") @DefaultValue("String_Node_Str") final String reason,@QueryParam("String_Node_Str") final List<String> passwords,@CookieParam("String_Node_Str") final String crowdTokenKey){
  checkForMainSource(request,sourceParam);
  final RpslObject primaryObject=lookupObjectByKey(keyParam,objectTypeParam);
  final Map<RpslObjectInfo,RpslObject> references=findReferences(primaryObject);
  validateReferences(primaryObject,references);
  try {
    if (references.isEmpty()) {
      performUpdate(request,primaryObject,reason,passwords,crowdTokenKey);
      return createResponse(request,primaryObject,Response.Status.OK);
    }
    final List<ActionRequest> actionRequests=Lists.newArrayList();
    final Set<RpslObject> allObjects=Sets.newHashSet(Iterables.concat(references.values(),Lists.newArrayList(primaryObject)));
    actionRequests.add(new ActionRequest(replaceReferencesInMntner(allObjects),Action.MODIFY));
    for (    final RpslObject rpslObject : allObjects) {
      if (!rpslObject.getType().equals(ObjectType.MNTNER)) {
        actionRequests.add(new ActionRequest(rpslObject,Action.DELETE));
      }
    }
    actionRequests.add(new ActionRequest(replaceReferencesInMntner(allObjects),Action.DELETE));
    performUpdates(request,actionRequests,passwords,crowdTokenKey,null);
    return createResponse(request,allObjects,Response.Status.OK);
  }
 catch (  WebApplicationException e) {
switch (e.getResponse().getStatus()) {
case HttpStatus.UNAUTHORIZED_401:
      throw new NotAuthorizedException(createResponse(request,primaryObject,Response.Status.UNAUTHORIZED));
case HttpStatus.INTERNAL_SERVER_ERROR_500:
    throw new InternalServerErrorException(createResponse(request,primaryObject,Response.Status.INTERNAL_SERVER_ERROR));
default :
  throw new BadRequestException(createResponse(request,primaryObject,Response.Status.BAD_REQUEST));
}
}
catch (ReferenceUpdateFailedException e) {
return createResponse(request,e.whoisResources,e.status);
}
catch (Exception e) {
LOGGER.error("String_Node_Str",e);
return createResponse(request,primaryObject,Response.Status.INTERNAL_SERVER_ERROR);
}
}

Fixed version (ground truth):
@DELETE @Consumes({MediaType.APPLICATION_XML,MediaType.APPLICATION_JSON}) @Produces({MediaType.APPLICATION_XML,MediaType.APPLICATION_JSON}) @Path("String_Node_Str") public Response delete(@Context final HttpServletRequest request,@PathParam("String_Node_Str") final String sourceParam,@PathParam("String_Node_Str") final String objectTypeParam,@PathParam("String_Node_Str") final String keyParam,@QueryParam("String_Node_Str") @DefaultValue("String_Node_Str") final String reason,@QueryParam("String_Node_Str") final List<String> passwords,@CookieParam("String_Node_Str") final String crowdTokenKey){
  checkForMainSource(request,sourceParam);
  final RpslObject primaryObject=lookupObjectByKey(keyParam,objectTypeParam);
  final Map<RpslObjectInfo,RpslObject> references=findReferences(primaryObject);
  validateReferences(primaryObject,references);
  try {
    if (references.isEmpty()) {
      performUpdate(request,primaryObject,reason,passwords,crowdTokenKey);
      return createResponse(request,primaryObject,Response.Status.OK);
    }
    final List<ActionRequest> actionRequests=Lists.newArrayList();
    final Set<RpslObject> allObjects=Sets.newHashSet(Iterables.concat(references.values(),Lists.newArrayList(primaryObject)));
    actionRequests.add(new ActionRequest(replaceReferencesInMntner(allObjects),Action.MODIFY));
    for (    final RpslObject rpslObject : allObjects) {
      if (!rpslObject.getType().equals(ObjectType.MNTNER)) {
        actionRequests.add(new ActionRequest(rpslObject,Action.DELETE));
      }
    }
    actionRequests.add(new ActionRequest(replaceReferencesInMntner(allObjects),Action.DELETE));
    performUpdates(request,actionRequests,passwords,crowdTokenKey,null,SsoAuthForm.UUID);
    return createResponse(request,allObjects,Response.Status.OK);
  }
 catch (  WebApplicationException e) {
switch (e.getResponse().getStatus()) {
case HttpStatus.UNAUTHORIZED_401:
      throw new NotAuthorizedException(createResponse(request,primaryObject,Response.Status.UNAUTHORIZED));
case HttpStatus.INTERNAL_SERVER_ERROR_500:
    throw new InternalServerErrorException(createResponse(request,primaryObject,Response.Status.INTERNAL_SERVER_ERROR));
default :
  throw new BadRequestException(createResponse(request,primaryObject,Response.Status.BAD_REQUEST));
}
}
catch (ReferenceUpdateFailedException e) {
return createResponse(request,e.whoisResources,e.status);
}
catch (Exception e) {
LOGGER.error("String_Node_Str",e);
return createResponse(request,primaryObject,Response.Status.INTERNAL_SERVER_ERROR);
}
}