Program: 86063
Project: 86063
Buggy source:
@PUT @Consumes("String_Node_Str") @Produces("String_Node_Str") @Path("String_Node_Str") public DocumentMasterDTO[] createNewVersion(@PathParam("String_Node_Str") String workspaceId,@PathParam("String_Node_Str") String docKey,DocumentCreationDTO docCreationDTO){
  int lastDash=docKey.lastIndexOf('-');
  String pID=docKey.substring(0,lastDash);
  String pVersion=docKey.substring(lastDash + 1,docKey.length());
  String pWorkspaceId=workspaceId;
  String pTitle=docCreationDTO.getTitle();
  String pDescription=docCreationDTO.getDescription();
  String pWorkflowModelId=docCreationDTO.getWorkflowModelId();
  ACLDTO acl=null;
  try {
    ACLUserEntry[] userEntries=null;
    ACLUserGroupEntry[] userGroupEntries=null;
    if (acl != null) {
      userEntries=new ACLUserEntry[acl.getUserEntries().size()];
      userGroupEntries=new ACLUserGroupEntry[acl.getGroupEntries().size()];
      int i=0;
      for (      Map.Entry<String,ACLDTO.Permission> entry : acl.getUserEntries().entrySet()) {
        userEntries[i]=new ACLUserEntry();
        userEntries[i].setPrincipal(new User(new Workspace(pWorkspaceId),entry.getKey()));
        userEntries[i++].setPermission(ACL.Permission.valueOf(entry.getValue().name()));
      }
      i=0;
      for (      Map.Entry<String,ACLDTO.Permission> entry : acl.getGroupEntries().entrySet()) {
        userGroupEntries[i]=new ACLUserGroupEntry();
        userGroupEntries[i].setPrincipal(new UserGroup(new Workspace(pWorkspaceId),entry.getKey()));
        userGroupEntries[i++].setPermission(ACL.Permission.valueOf(entry.getValue().name()));
      }
    }
    DocumentMaster[] docM=documentService.createVersion(new DocumentMasterKey(pWorkspaceId,pID,pVersion),pTitle,pDescription,pWorkflowModelId,userEntries,userGroupEntries);
    DocumentMasterDTO[] dtos=new DocumentMasterDTO[docM.length];
    for (int i=0; i < docM.length; i++) {
      dtos[i]=mapper.map(docM[i],DocumentMasterDTO.class);
      dtos[i].setPath(docM[i].getLocation().getCompletePath());
      dtos[i].setLifeCycleState(docM[i].getLifeCycleState());
      dtos[i]=Tools.createLightDocumentMasterDTO(dtos[i]);
    }
    return dtos;
  }
 catch (  com.docdoku.core.services.ApplicationException ex) {
    throw new RestApiException(ex.toString(),ex.getMessage());
  }
}

Fixed version (ground truth):
@PUT @Consumes("String_Node_Str") @Produces("String_Node_Str") @Path("String_Node_Str") public DocumentMasterDTO[] createNewVersion(@PathParam("String_Node_Str") String workspaceId,@PathParam("String_Node_Str") String docKey,DocumentCreationDTO docCreationDTO){
  int lastDash=docKey.lastIndexOf('-');
  String pID=docKey.substring(0,lastDash);
  String pVersion=docKey.substring(lastDash + 1,docKey.length());
  String pWorkspaceId=workspaceId;
  String pTitle=docCreationDTO.getTitle();
  String pDescription=docCreationDTO.getDescription();
  String pWorkflowModelId=docCreationDTO.getWorkflowModelId();
  ACLDTO acl=null;
  try {
    ACLUserEntry[] userEntries=null;
    ACLUserGroupEntry[] userGroupEntries=null;
    if (acl != null) {
      userEntries=new ACLUserEntry[acl.getUserEntries().size()];
      userGroupEntries=new ACLUserGroupEntry[acl.getGroupEntries().size()];
      int i=0;
      for (      Map.Entry<String,ACLDTO.Permission> entry : acl.getUserEntries().entrySet()) {
        userEntries[i]=new ACLUserEntry();
        userEntries[i].setPrincipal(new User(new Workspace(pWorkspaceId),entry.getKey()));
        userEntries[i++].setPermission(ACL.Permission.valueOf(entry.getValue().name()));
      }
      i=0;
      for (      Map.Entry<String,ACLDTO.Permission> entry : acl.getGroupEntries().entrySet()) {
        userGroupEntries[i]=new ACLUserGroupEntry();
        userGroupEntries[i].setPrincipal(new UserGroup(new Workspace(pWorkspaceId),entry.getKey()));
        userGroupEntries[i++].setPermission(ACL.Permission.valueOf(entry.getValue().name()));
      }
    }
    DocumentMaster[] docM=documentService.createVersion(new DocumentMasterKey(pWorkspaceId,pID,pVersion),pTitle,pDescription,pWorkflowModelId,userEntries,userGroupEntries);
    DocumentMasterDTO[] dtos=new DocumentMasterDTO[docM.length];
    for (int i=0; i < docM.length; i++) {
      dtos[i]=mapper.map(docM[i],DocumentMasterDTO.class);
      dtos[i].setPath(docM[i].getLocation().getCompletePath());
      dtos[i].setLifeCycleState(docM[i].getLifeCycleState());
      dtos[i]=Tools.createLightDocumentMasterDTO(dtos[i]);
      dtos[i].setIterationSubscription(documentService.isUserIterationChangeEventSubscribedForGivenDocument(workspaceId,docM[i]));
      dtos[i].setStateSubscription(documentService.isUserStateChangeEventSubscribedForGivenDocument(workspaceId,docM[i]));
    }
    return dtos;
  }
 catch (  com.docdoku.core.services.ApplicationException ex) {
    throw new RestApiException(ex.toString(),ex.getMessage());
  }
}