Program: 160969
Project: 160969
Buggy source:
@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);
}
}

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)));
    final RpslObjectWithReplacements tmpMntnerWithReplacements=replaceReferencesInMntner(allObjects);
    actionRequests.add(new ActionRequest(tmpMntnerWithReplacements.rpslObject,Action.MODIFY));
    for (    final RpslObject rpslObject : allObjects) {
      if (!rpslObject.getType().equals(ObjectType.MNTNER)) {
        actionRequests.add(new ActionRequest(rpslObject,Action.DELETE));
      }
    }
    actionRequests.add(new ActionRequest(tmpMntnerWithReplacements.rpslObject,Action.DELETE));
    final WhoisResources whoisResources=performUpdates(request,actionRequests,passwords,crowdTokenKey,null,SsoAuthForm.UUID);
    removeDuplicatesAndRestoreReplacedReferences(whoisResources,tmpMntnerWithReplacements);
    return createResponse(request,whoisResources,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);
}
}