Program: 172169
Project: 172169
Buggy source:
/** 
 * Returns the variant of the object.
 */
public ObjectVariantEnum getObjectVariant(String objectId){
  if (objectId == null) {
    return ObjectVariantEnum.INVALID_ID;
  }
  try {
    String nodeRefString=objectId;
    String versionString=null;
    int sepIndex=objectId.lastIndexOf(ID_SEPERATOR);
    if (sepIndex > -1) {
      nodeRefString=objectId.substring(0,sepIndex);
      versionString=objectId.substring(sepIndex + 1);
    }
    if (NodeRef.isNodeRef(nodeRefString)) {
      NodeRef nodeRef=new NodeRef(nodeRefString);
      if (!nodeService.exists(nodeRef)) {
        return ObjectVariantEnum.NOT_EXISTING;
      }
      if (nodeService.hasAspect(nodeRef,ContentModel.ASPECT_WORKING_COPY)) {
        return ObjectVariantEnum.PWC;
      }
      if (versionString == null) {
        return ObjectVariantEnum.NODE;
      }
      VersionHistory versionHistory=versionService.getVersionHistory(nodeRef);
      if (versionHistory == null) {
        if (versionString.equals(UNVERSIONED_VERSION_LABEL)) {
          return ObjectVariantEnum.NODE;
        }
        return ObjectVariantEnum.NOT_EXISTING;
      }
      try {
        versionHistory.getVersion(versionString);
        return ObjectVariantEnum.VERSION;
      }
 catch (      VersionDoesNotExistException e) {
        return ObjectVariantEnum.NOT_EXISTING;
      }
    }
 else     if (objectId.startsWith(ASSOC_ID_PREFIX)) {
      Long assocId=null;
      try {
        assocId=new Long(objectId.substring(ASSOC_ID_PREFIX.length()));
      }
 catch (      NumberFormatException nfe) {
        return ObjectVariantEnum.INVALID_ID;
      }
      AssociationRef associationRef=nodeService.getAssoc(assocId);
      if (associationRef == null) {
        return ObjectVariantEnum.NOT_EXISTING;
      }
      return ObjectVariantEnum.ASSOC;
    }
 else {
      return ObjectVariantEnum.INVALID_ID;
    }
  }
 catch (  AccessDeniedException e) {
    return ObjectVariantEnum.PERMISSION_DENIED;
  }
}

Fixed version (ground truth):
/** 
 * Returns the variant of the object.
 */
public ObjectVariantEnum getObjectVariant(String objectId){
  if (objectId == null) {
    return ObjectVariantEnum.INVALID_ID;
  }
  try {
    String nodeRefString=objectId;
    String versionString=null;
    int sepIndex=objectId.lastIndexOf(ID_SEPERATOR);
    if (sepIndex > -1) {
      nodeRefString=objectId.substring(0,sepIndex);
      versionString=objectId.substring(sepIndex + 1);
    }
    if (NodeRef.isNodeRef(nodeRefString)) {
      NodeRef nodeRef=new NodeRef(nodeRefString);
      if (!nodeService.exists(nodeRef)) {
        return ObjectVariantEnum.NOT_EXISTING;
      }
      if (nodeService.hasAspect(nodeRef,ContentModel.ASPECT_WORKING_COPY)) {
        return ObjectVariantEnum.PWC;
      }
      if (versionString == null) {
        return ObjectVariantEnum.NODE;
      }
      VersionHistory versionHistory=versionService.getVersionHistory(nodeRef);
      if (versionHistory == null) {
        if (versionString.equals(UNVERSIONED_VERSION_LABEL)) {
          return ObjectVariantEnum.NODE;
        }
        return ObjectVariantEnum.NOT_EXISTING;
      }
      try {
        versionHistory.getVersion(versionString);
        if (versionString.equals(versionHistory.getHeadVersion().getVersionLabel())) {
          return ObjectVariantEnum.NODE;
        }
        return ObjectVariantEnum.VERSION;
      }
 catch (      VersionDoesNotExistException e) {
        return ObjectVariantEnum.NOT_EXISTING;
      }
    }
 else     if (objectId.startsWith(ASSOC_ID_PREFIX)) {
      Long assocId=null;
      try {
        assocId=new Long(objectId.substring(ASSOC_ID_PREFIX.length()));
      }
 catch (      NumberFormatException nfe) {
        return ObjectVariantEnum.INVALID_ID;
      }
      AssociationRef associationRef=nodeService.getAssoc(assocId);
      if (associationRef == null) {
        return ObjectVariantEnum.NOT_EXISTING;
      }
      return ObjectVariantEnum.ASSOC;
    }
 else {
      return ObjectVariantEnum.INVALID_ID;
    }
  }
 catch (  AccessDeniedException e) {
    return ObjectVariantEnum.PERMISSION_DENIED;
  }
}