Program: 52050
Project: 52050
Buggy source:
/** 
 * Create item in collection. Item can be without filled metadata.
 * @param collectionId Id of collection in which will be item created.
 * @param item Item filled only with metadata, other variables are ignored.
 * @param headers If you want to access to collection under logged user into context. In headers must be set header "rest-dspace-token" with passed token from login method.
 * @return Return status code with item. Return status (OK)200 if item wascreated. NOT_FOUND(404) if id of collection does not exists. UNAUTHORIZED(401) if user have not permission to write items in collection.
 * @throws WebApplicationException It is thrown when was problem with database reading or writing (SQLException) or problem with creating context(ContextException) or problem with authorization to collection or IOException or problem with index item into browse index. It is thrown by NOT_FOUND and UNATHORIZED status codes, too.
 */
@POST @Path("String_Node_Str") @Consumes({MediaType.APPLICATION_JSON,MediaType.APPLICATION_XML}) public Item addCollectionItem(@PathParam("String_Node_Str") Integer collectionId,Item item,@QueryParam("String_Node_Str") String user_ip,@QueryParam("String_Node_Str") String user_agent,@QueryParam("String_Node_Str") String xforwarderfor,@Context HttpHeaders headers,@Context HttpServletRequest request) throws WebApplicationException {
  log.info("String_Node_Str" + collectionId + "String_Node_Str");
  org.dspace.core.Context context=null;
  Item returnItem=null;
  try {
    context=createContext(getUser(headers));
    org.dspace.content.Collection dspaceCollection=findCollection(context,collectionId,org.dspace.core.Constants.WRITE);
    writeStats(dspaceCollection,UsageEvent.Action.UPDATE,user_ip,user_agent,xforwarderfor,headers,request);
    log.trace("String_Node_Str" + collectionId + "String_Node_Str");
    org.dspace.content.WorkspaceItem workspaceItem=org.dspace.content.WorkspaceItem.create(context,dspaceCollection,false);
    org.dspace.content.Item dspaceItem=workspaceItem.getItem();
    log.trace("String_Node_Str" + dspaceItem.getID() + "String_Node_Str");
    if (item.getMetadata() != null) {
      for (      MetadataEntry entry : item.getMetadata()) {
        String data[]=mySplit(entry.getKey());
        dspaceItem.addMetadata(data[0],data[1],data[2],entry.getLanguage(),entry.getValue());
      }
    }
    workspaceItem.update();
    org.dspace.browse.IndexBrowse browse=new org.dspace.browse.IndexBrowse();
    browse.indexItem(dspaceItem);
    log.trace("String_Node_Str" + collectionId + "String_Node_Str");
    dspaceItem=org.dspace.content.InstallItem.installItem(context,workspaceItem);
    returnItem=new Item(dspaceItem,"String_Node_Str",context);
    context.complete();
  }
 catch (  SQLException e) {
    processException("String_Node_Str" + collectionId + "String_Node_Str"+ e,context);
  }
catch (  AuthorizeException e) {
    processException("String_Node_Str" + collectionId + "String_Node_Str"+ e,context);
  }
catch (  IOException e) {
    processException("String_Node_Str" + collectionId + "String_Node_Str"+ e,context);
  }
catch (  BrowseException e) {
    processException("String_Node_Str" + e,context);
  }
catch (  ContextException e) {
    processException("String_Node_Str" + collectionId + "String_Node_Str"+ e.getMessage(),context);
  }
 finally {
    processFinally(context);
  }
  log.info("String_Node_Str" + collectionId + "String_Node_Str"+ returnItem.getHandle());
  return returnItem;
}

Fixed version (ground truth):
/** 
 * Create item in collection. Item can be without filled metadata.
 * @param collectionId Id of collection in which will be item created.
 * @param item Item filled only with metadata, other variables are ignored.
 * @param headers If you want to access to collection under logged user into context. In headers must be set header "rest-dspace-token" with passed token from login method.
 * @return Return status code with item. Return status (OK)200 if item wascreated. NOT_FOUND(404) if id of collection does not exists. UNAUTHORIZED(401) if user have not permission to write items in collection.
 * @throws WebApplicationException It is thrown when was problem with database reading or writing (SQLException) or problem with creating context(ContextException) or problem with authorization to collection or IOException or problem with index item into browse index. It is thrown by NOT_FOUND and UNATHORIZED status codes, too.
 */
@POST @Path("String_Node_Str") @Consumes({MediaType.APPLICATION_JSON,MediaType.APPLICATION_XML}) public Item addCollectionItem(@PathParam("String_Node_Str") Integer collectionId,Item item,@QueryParam("String_Node_Str") String user_ip,@QueryParam("String_Node_Str") String user_agent,@QueryParam("String_Node_Str") String xforwarderfor,@Context HttpHeaders headers,@Context HttpServletRequest request) throws WebApplicationException {
  log.info("String_Node_Str" + collectionId + "String_Node_Str");
  org.dspace.core.Context context=null;
  Item returnItem=null;
  try {
    context=createContext(getUser(headers));
    org.dspace.content.Collection dspaceCollection=findCollection(context,collectionId,org.dspace.core.Constants.WRITE);
    writeStats(dspaceCollection,UsageEvent.Action.UPDATE,user_ip,user_agent,xforwarderfor,headers,request,context);
    log.trace("String_Node_Str" + collectionId + "String_Node_Str");
    org.dspace.content.WorkspaceItem workspaceItem=org.dspace.content.WorkspaceItem.create(context,dspaceCollection,false);
    org.dspace.content.Item dspaceItem=workspaceItem.getItem();
    log.trace("String_Node_Str" + dspaceItem.getID() + "String_Node_Str");
    if (item.getMetadata() != null) {
      for (      MetadataEntry entry : item.getMetadata()) {
        String data[]=mySplit(entry.getKey());
        dspaceItem.addMetadata(data[0],data[1],data[2],entry.getLanguage(),entry.getValue());
      }
    }
    workspaceItem.update();
    org.dspace.browse.IndexBrowse browse=new org.dspace.browse.IndexBrowse();
    browse.indexItem(dspaceItem);
    log.trace("String_Node_Str" + collectionId + "String_Node_Str");
    dspaceItem=org.dspace.content.InstallItem.installItem(context,workspaceItem);
    returnItem=new Item(dspaceItem,"String_Node_Str",context);
    context.complete();
  }
 catch (  SQLException e) {
    processException("String_Node_Str" + collectionId + "String_Node_Str"+ e,context);
  }
catch (  AuthorizeException e) {
    processException("String_Node_Str" + collectionId + "String_Node_Str"+ e,context);
  }
catch (  IOException e) {
    processException("String_Node_Str" + collectionId + "String_Node_Str"+ e,context);
  }
catch (  BrowseException e) {
    processException("String_Node_Str" + e,context);
  }
catch (  ContextException e) {
    processException("String_Node_Str" + collectionId + "String_Node_Str"+ e.getMessage(),context);
  }
 finally {
    processFinally(context);
  }
  log.info("String_Node_Str" + collectionId + "String_Node_Str"+ returnItem.getHandle());
  return returnItem;
}