Program: 102434
Project: 102434
Buggy source:
@DELETE @Path("String_Node_Str") @RolesAllowed("String_Node_Str") @ApiOperation(value="String_Node_Str",httpMethod="String_Node_Str",response=Response.class,notes="String_Node_Str") @ApiResponses(value={@ApiResponse(code=200,message="String_Node_Str"),@ApiResponse(code=500,message="String_Node_Str"),@ApiResponse(code=400,message="String_Node_Str")}) public Response deleteLike(@Context UriInfo uriInfo,@ApiParam(value="String_Node_Str",required=true) @PathParam("String_Node_Str") String id,@ApiParam(value="String_Node_Str",required=true) @PathParam("String_Node_Str") String username,@ApiParam(value="String_Node_Str",required=false) @QueryParam("String_Node_Str") String expand) throws Exception {
  String authenticatedUser=ConversationState.getCurrent().getIdentity().getUserId();
  if (authenticatedUser.equals(username)) {
    throw new WebApplicationException(Response.Status.UNAUTHORIZED);
  }
  Identity currentUser=CommonsUtils.getService(IdentityManager.class).getOrCreateIdentity(OrganizationIdentityProvider.NAME,authenticatedUser,true);
  ActivityManager activityManager=CommonsUtils.getService(ActivityManager.class);
  ExoSocialActivity activity=activityManager.getActivity(id);
  if (activity == null) {
    throw new WebApplicationException(Response.Status.UNAUTHORIZED);
  }
  List<String> likerIds=Arrays.asList(activity.getLikeIdentityIds());
  if (likerIds.contains(currentUser.getId())) {
    likerIds.remove(currentUser.getId());
    String[] identityIds=new String[likerIds.size()];
    activity.setLikeIdentityIds(likerIds.toArray(identityIds));
    activityManager.updateActivity(activity);
  }
  return EntityBuilder.getResponse(EntityBuilder.buildEntityFromActivity(activityManager.getActivity(id),uriInfo.getPath(),expand),uriInfo,RestUtils.getJsonMediaType(),Response.Status.OK);
}

Fixed version (ground truth):
@DELETE @Path("String_Node_Str") @RolesAllowed("String_Node_Str") @ApiOperation(value="String_Node_Str",httpMethod="String_Node_Str",response=Response.class,notes="String_Node_Str") @ApiResponses(value={@ApiResponse(code=200,message="String_Node_Str"),@ApiResponse(code=500,message="String_Node_Str"),@ApiResponse(code=400,message="String_Node_Str")}) public Response deleteLike(@Context UriInfo uriInfo,@ApiParam(value="String_Node_Str",required=true) @PathParam("String_Node_Str") String id,@ApiParam(value="String_Node_Str",required=true) @PathParam("String_Node_Str") String username,@ApiParam(value="String_Node_Str",required=false) @QueryParam("String_Node_Str") String expand) throws Exception {
  String authenticatedUser=ConversationState.getCurrent().getIdentity().getUserId();
  if (!authenticatedUser.equals(username)) {
    throw new WebApplicationException(Response.Status.UNAUTHORIZED);
  }
  Identity currentUser=CommonsUtils.getService(IdentityManager.class).getOrCreateIdentity(OrganizationIdentityProvider.NAME,authenticatedUser,true);
  ActivityManager activityManager=CommonsUtils.getService(ActivityManager.class);
  ExoSocialActivity activity=activityManager.getActivity(id);
  if (activity == null) {
    throw new WebApplicationException(Response.Status.UNAUTHORIZED);
  }
  List<String> likerIds=new ArrayList<String>(Arrays.asList(activity.getLikeIdentityIds()));
  if (likerIds.contains(currentUser.getId())) {
    likerIds.remove(currentUser.getId());
    String[] identityIds=new String[likerIds.size()];
    activity.setLikeIdentityIds(likerIds.toArray(identityIds));
    activityManager.updateActivity(activity);
  }
  return EntityBuilder.getResponse(EntityBuilder.buildEntityFromActivity(activityManager.getActivity(id),uriInfo.getPath(),expand),uriInfo,RestUtils.getJsonMediaType(),Response.Status.OK);
}