Program: 179176
Project: 179176
Buggy source:
/** 
 * adding an array of json documents, where each item in the array is service endpoint information
 * @throws InterruptedException TODO: polymorphic registrations: Supporting JSONObject as well as Array
 * @throws JSONException
 */
@POST @Consumes({MediaType.APPLICATION_JSON}) @Produces({MediaType.APPLICATION_JSON}) public Response registerServices(JSONArray serviceInfos) throws WebApplicationException, InterruptedException, JSONException {
  Long max=Long.valueOf(DSRServer.getProperty(ServerConstants.REGISTRY_MAX_REGISTRATIONS,"String_Node_Str"));
  if (serviceInfos.length() > max) {
    return Response.status(Status.FORBIDDEN).entity(new String("String_Node_Str" + max)).build();
  }
  JSONObject serviceInfo=null;
  JSONArray arr=new JSONArray();
  JSONArray errorArray=new JSONArray();
  for (int i=0; i < serviceInfos.length(); i++) {
    try {
      serviceInfo=serviceInfos.getJSONObject(i);
      Integer length=serviceInfo.length();
      if (length <= 0 || length > 100) {
        throw new WebApplicationException(Status.FORBIDDEN);
      }
      String serviceurl=serviceInfo.getString(ServiceBasicAttributeNames.SERVICE_ENDPOINT_URL.getAttributeName());
      String messageTime="String_Node_Str";
      if (serviceInfo.has(ServiceBasicAttributeNames.SERVICE_UPDATE_SINCE.getAttributeName())) {
        messageTime=(serviceInfo.getJSONObject(ServiceBasicAttributeNames.SERVICE_UPDATE_SINCE.getAttributeName())).getString("String_Node_Str");
      }
      Client c=(Client)req.getAttribute("String_Node_Str");
      JSONObject res=null;
      if (c.getRole().getName().equalsIgnoreCase("String_Node_Str")) {
        if (!serviceInfo.has(ServiceBasicAttributeNames.SERVICE_OWNER.getAttributeName())) {
          serviceInfo.put(ServiceBasicAttributeNames.SERVICE_OWNER.getAttributeName(),c.getDistinguishedName());
        }
        if (serviceAdmin.checkMessageGenerationTime(messageTime,serviceurl)) {
          res=serviceAdmin.addService(serviceInfo);
        }
      }
 else {
        if (serviceAdmin.checkMessageGenerationTime(messageTime,serviceurl)) {
          serviceInfo.put(ServiceBasicAttributeNames.SERVICE_OWNER.getAttributeName(),c.getDistinguishedName());
          res=serviceAdmin.addService(serviceInfo);
        }
      }
      arr.put(res);
      continue;
    }
 catch (    ExistingResourceException e) {
      errorArray.put(serviceInfo);
    }
catch (    Exception e) {
      JSONObject jErr=new JSONObject();
      jErr.put("String_Node_Str",e.getCause());
      throw new WebApplicationException(Response.status(Status.INTERNAL_SERVER_ERROR).entity(jErr).build());
    }
  }
  EventDispatcher.notifyRecievers(new Event(EventTypes.SERVICE_ADD,arr));
  if (errorArray.length() > 0) {
    return Response.status(Status.CONFLICT).entity(errorArray).build();
  }
  return Response.ok(arr).build();
}

Fixed version (ground truth):
/** 
 * adding an array of json documents, where each item in the array is service endpoint information
 * @throws InterruptedException TODO: polymorphic registrations: Supporting JSONObject as well as Array
 * @throws JSONException
 */
@POST @Consumes({MediaType.APPLICATION_JSON}) @Produces({MediaType.APPLICATION_JSON}) public Response registerServices(JSONArray serviceInfos) throws WebApplicationException, InterruptedException, JSONException {
  Long max=Long.valueOf(DSRServer.getProperty(ServerConstants.REGISTRY_MAX_REGISTRATIONS,"String_Node_Str"));
  if (serviceInfos.length() > max) {
    return Response.status(Status.FORBIDDEN).entity(new String("String_Node_Str" + max)).build();
  }
  JSONObject serviceInfo=null;
  JSONArray arr=new JSONArray();
  JSONArray errorArray=new JSONArray();
  for (int i=0; i < serviceInfos.length(); i++) {
    try {
      serviceInfo=serviceInfos.getJSONObject(i);
      Integer length=serviceInfo.length();
      if (length <= 0 || length > 100) {
        throw new WebApplicationException(Status.FORBIDDEN);
      }
      String serviceurl=serviceInfo.getString(ServiceBasicAttributeNames.SERVICE_ENDPOINT_URL.getAttributeName());
      String messageTime="String_Node_Str";
      if (serviceInfo.has(ServiceBasicAttributeNames.SERVICE_UPDATE_SINCE.getAttributeName())) {
        messageTime=(serviceInfo.getJSONObject(ServiceBasicAttributeNames.SERVICE_UPDATE_SINCE.getAttributeName())).getString("String_Node_Str");
      }
      Client c=(Client)req.getAttribute("String_Node_Str");
      JSONObject res=null;
      if (c.getRole().getName().equalsIgnoreCase("String_Node_Str")) {
        if (!serviceInfo.has(ServiceBasicAttributeNames.SERVICE_OWNER.getAttributeName())) {
          serviceInfo.put(ServiceBasicAttributeNames.SERVICE_OWNER.getAttributeName(),c.getDistinguishedName());
        }
        if (serviceAdmin.checkMessageGenerationTime(messageTime,serviceurl)) {
          res=serviceAdmin.addService(serviceInfo);
        }
      }
 else {
        if (serviceAdmin.checkMessageGenerationTime(messageTime,serviceurl)) {
          serviceInfo.put(ServiceBasicAttributeNames.SERVICE_OWNER.getAttributeName(),c.getDistinguishedName());
          res=serviceAdmin.addService(serviceInfo);
        }
      }
      if (res != null) {
        arr.put(res);
      }
      continue;
    }
 catch (    ExistingResourceException e) {
      errorArray.put(serviceInfo);
    }
catch (    Exception e) {
      JSONObject jErr=new JSONObject();
      jErr.put("String_Node_Str",e.getCause());
      throw new WebApplicationException(Response.status(Status.INTERNAL_SERVER_ERROR).entity(jErr).build());
    }
  }
  EventDispatcher.notifyRecievers(new Event(EventTypes.SERVICE_ADD,arr));
  if (errorArray.length() > 0) {
    return Response.status(Status.CONFLICT).entity(errorArray).build();
  }
  return Response.ok(arr).build();
}