Program: 112220
Project: 112220
Buggy source:
/** 
 * @return Returns a set containing all of the parameter names thatwere found to have a value
 */
@SuppressWarnings("String_Node_Str") protected Set<String> extractResourceLinks(ResourceTable theEntity,IBaseResource theResource,Set<ResourceLink> theLinks,Date theUpdateTime){
  HashSet<String> retVal=new HashSet<String>();
  if (theResource instanceof IBaseBundle) {
    return Collections.emptySet();
  }
  Map<String,RuntimeSearchParam> searchParams=mySearchParamRegistry.getActiveSearchParams(toResourceName(theResource.getClass()));
  for (  RuntimeSearchParam nextSpDef : searchParams.values()) {
    if (nextSpDef.getParamType() != RestSearchParameterTypeEnum.REFERENCE) {
      continue;
    }
    String nextPathsUnsplit=nextSpDef.getPath();
    if (isBlank(nextPathsUnsplit)) {
      continue;
    }
    boolean multiType=false;
    if (nextPathsUnsplit.endsWith("String_Node_Str")) {
      multiType=true;
    }
    List<PathAndRef> refs=mySearchParamExtractor.extractResourceLinks(theResource,nextSpDef);
    for (    PathAndRef nextPathAndRef : refs) {
      Object nextObject=nextPathAndRef.getRef();
      if (nextObject instanceof IBaseExtension<?,?>) {
        nextObject=((IBaseExtension<?,?>)nextObject).getValue();
      }
      IIdType nextId;
      if (nextObject instanceof IBaseReference) {
        IBaseReference nextValue=(IBaseReference)nextObject;
        if (nextValue.isEmpty()) {
          continue;
        }
        nextId=nextValue.getReferenceElement();
        if (nextId.isEmpty() || nextId.getValue().startsWith("String_Node_Str")) {
          continue;
        }
      }
 else       if (nextObject instanceof IBaseResource) {
        nextId=((IBaseResource)nextObject).getIdElement();
        if (nextId == null || nextId.hasIdPart() == false) {
          continue;
        }
      }
 else       if (myContext.getElementDefinition((Class<? extends IBase>)nextObject.getClass()).getName().equals("String_Node_Str")) {
        continue;
      }
 else {
        if (!multiType) {
          if (nextSpDef.getName().equals("String_Node_Str")) {
            continue;
          }
          throw new ConfigurationException("String_Node_Str" + nextSpDef.getName() + "String_Node_Str"+ nextObject.getClass());
        }
 else {
          continue;
        }
      }
      retVal.add(nextSpDef.getName());
      if (isLogicalReference(nextId)) {
        ResourceLink resourceLink=new ResourceLink(nextPathAndRef.getPath(),theEntity,nextId,theUpdateTime);
        if (theLinks.add(resourceLink)) {
          ourLog.debug("String_Node_Str",nextId);
        }
        continue;
      }
      String baseUrl=nextId.getBaseUrl();
      String typeString=nextId.getResourceType();
      if (isBlank(typeString)) {
        throw new InvalidRequestException("String_Node_Str" + nextPathsUnsplit + "String_Node_Str"+ nextId.getValue());
      }
      RuntimeResourceDefinition resourceDefinition;
      try {
        resourceDefinition=getContext().getResourceDefinition(typeString);
      }
 catch (      DataFormatException e) {
        throw new InvalidRequestException("String_Node_Str" + nextPathsUnsplit + "String_Node_Str"+ nextId.getValue());
      }
      if (isNotBlank(baseUrl)) {
        if (!getConfig().getTreatBaseUrlsAsLocal().contains(baseUrl) && !getConfig().isAllowExternalReferences()) {
          String msg=getContext().getLocalizer().getMessage(BaseHapiFhirDao.class,"String_Node_Str",nextId.getValue());
          throw new InvalidRequestException(msg);
        }
 else {
          ResourceLink resourceLink=new ResourceLink(nextPathAndRef.getPath(),theEntity,nextId,theUpdateTime);
          if (theLinks.add(resourceLink)) {
            ourLog.info("String_Node_Str",nextId);
          }
          continue;
        }
      }
      Class<? extends IBaseResource> type=resourceDefinition.getImplementingClass();
      String id=nextId.getIdPart();
      if (StringUtils.isBlank(id)) {
        throw new InvalidRequestException("String_Node_Str" + nextPathsUnsplit + "String_Node_Str"+ nextId.getValue());
      }
      IFhirResourceDao<?> dao=getDao(type);
      if (dao == null) {
        StringBuilder b=new StringBuilder();
        b.append("String_Node_Str");
        b.append(myContext.getVersion().getVersion());
        b.append("String_Node_Str");
        b.append(nextId.getResourceType());
        b.append("String_Node_Str");
        b.append(myResourceTypeToDao.keySet().toString());
        throw new InvalidRequestException(b.toString());
      }
      Long valueOf;
      try {
        valueOf=translateForcedIdToPid(typeString,id);
      }
 catch (      ResourceNotFoundException e) {
        if (myConfig.isEnforceReferentialIntegrityOnWrite() == false) {
          continue;
        }
        String resName=getContext().getResourceDefinition(type).getName();
        throw new InvalidRequestException("String_Node_Str" + resName + "String_Node_Str"+ id+ "String_Node_Str"+ nextPathsUnsplit);
      }
      ResourceTable target=myEntityManager.find(ResourceTable.class,valueOf);
      RuntimeResourceDefinition targetResourceDef=getContext().getResourceDefinition(type);
      if (target == null) {
        String resName=targetResourceDef.getName();
        throw new InvalidRequestException("String_Node_Str" + resName + "String_Node_Str"+ id+ "String_Node_Str"+ nextPathsUnsplit);
      }
      if (!typeString.equals(target.getResourceType())) {
        throw new UnprocessableEntityException("String_Node_Str" + nextId.getValue() + "String_Node_Str"+ nextId.getIdPart()+ "String_Node_Str"+ target.getResourceType());
      }
      if (nextSpDef.getTargets() != null && !nextSpDef.getTargets().contains(typeString)) {
        continue;
      }
      ResourceLink resourceLink=new ResourceLink(nextPathAndRef.getPath(),theEntity,target,theUpdateTime);
      theLinks.add(resourceLink);
    }
  }
  theEntity.setHasLinks(theLinks.size() > 0);
  return retVal;
}

Fixed version (ground truth):
/** 
 * @return Returns a set containing all of the parameter names thatwere found to have a value
 */
@SuppressWarnings("String_Node_Str") protected Set<String> extractResourceLinks(ResourceTable theEntity,IBaseResource theResource,Set<ResourceLink> theLinks,Date theUpdateTime){
  HashSet<String> retVal=new HashSet<String>();
  if (theResource instanceof IBaseBundle) {
    return Collections.emptySet();
  }
  Map<String,RuntimeSearchParam> searchParams=mySearchParamRegistry.getActiveSearchParams(toResourceName(theResource.getClass()));
  for (  RuntimeSearchParam nextSpDef : searchParams.values()) {
    if (nextSpDef.getParamType() != RestSearchParameterTypeEnum.REFERENCE) {
      continue;
    }
    String nextPathsUnsplit=nextSpDef.getPath();
    if (isBlank(nextPathsUnsplit)) {
      continue;
    }
    boolean multiType=false;
    if (nextPathsUnsplit.endsWith("String_Node_Str")) {
      multiType=true;
    }
    List<PathAndRef> refs=mySearchParamExtractor.extractResourceLinks(theResource,nextSpDef);
    for (    PathAndRef nextPathAndRef : refs) {
      Object nextObject=nextPathAndRef.getRef();
      if (nextObject instanceof IBaseExtension<?,?>) {
        nextObject=((IBaseExtension<?,?>)nextObject).getValue();
      }
      IIdType nextId;
      if (nextObject instanceof IBaseReference) {
        IBaseReference nextValue=(IBaseReference)nextObject;
        if (nextValue.isEmpty()) {
          continue;
        }
        nextId=nextValue.getReferenceElement();
        if (nextId.isEmpty() && nextValue.getResource() != null) {
          nextId=nextValue.getResource().getIdElement();
        }
        if (nextId.isEmpty() || nextId.getValue().startsWith("String_Node_Str")) {
          continue;
        }
      }
 else       if (nextObject instanceof IBaseResource) {
        nextId=((IBaseResource)nextObject).getIdElement();
        if (nextId == null || nextId.hasIdPart() == false) {
          continue;
        }
      }
 else       if (myContext.getElementDefinition((Class<? extends IBase>)nextObject.getClass()).getName().equals("String_Node_Str")) {
        continue;
      }
 else {
        if (!multiType) {
          if (nextSpDef.getName().equals("String_Node_Str")) {
            continue;
          }
          throw new ConfigurationException("String_Node_Str" + nextSpDef.getName() + "String_Node_Str"+ nextObject.getClass());
        }
 else {
          continue;
        }
      }
      retVal.add(nextSpDef.getName());
      if (isLogicalReference(nextId)) {
        ResourceLink resourceLink=new ResourceLink(nextPathAndRef.getPath(),theEntity,nextId,theUpdateTime);
        if (theLinks.add(resourceLink)) {
          ourLog.debug("String_Node_Str",nextId);
        }
        continue;
      }
      String baseUrl=nextId.getBaseUrl();
      String typeString=nextId.getResourceType();
      if (isBlank(typeString)) {
        throw new InvalidRequestException("String_Node_Str" + nextPathsUnsplit + "String_Node_Str"+ nextId.getValue());
      }
      RuntimeResourceDefinition resourceDefinition;
      try {
        resourceDefinition=getContext().getResourceDefinition(typeString);
      }
 catch (      DataFormatException e) {
        throw new InvalidRequestException("String_Node_Str" + nextPathsUnsplit + "String_Node_Str"+ nextId.getValue());
      }
      if (isNotBlank(baseUrl)) {
        if (!getConfig().getTreatBaseUrlsAsLocal().contains(baseUrl) && !getConfig().isAllowExternalReferences()) {
          String msg=getContext().getLocalizer().getMessage(BaseHapiFhirDao.class,"String_Node_Str",nextId.getValue());
          throw new InvalidRequestException(msg);
        }
 else {
          ResourceLink resourceLink=new ResourceLink(nextPathAndRef.getPath(),theEntity,nextId,theUpdateTime);
          if (theLinks.add(resourceLink)) {
            ourLog.info("String_Node_Str",nextId);
          }
          continue;
        }
      }
      Class<? extends IBaseResource> type=resourceDefinition.getImplementingClass();
      String id=nextId.getIdPart();
      if (StringUtils.isBlank(id)) {
        throw new InvalidRequestException("String_Node_Str" + nextPathsUnsplit + "String_Node_Str"+ nextId.getValue());
      }
      IFhirResourceDao<?> dao=getDao(type);
      if (dao == null) {
        StringBuilder b=new StringBuilder();
        b.append("String_Node_Str");
        b.append(myContext.getVersion().getVersion());
        b.append("String_Node_Str");
        b.append(nextId.getResourceType());
        b.append("String_Node_Str");
        b.append(myResourceTypeToDao.keySet().toString());
        throw new InvalidRequestException(b.toString());
      }
      Long valueOf;
      try {
        valueOf=translateForcedIdToPid(typeString,id);
      }
 catch (      ResourceNotFoundException e) {
        if (myConfig.isEnforceReferentialIntegrityOnWrite() == false) {
          continue;
        }
        String resName=getContext().getResourceDefinition(type).getName();
        throw new InvalidRequestException("String_Node_Str" + resName + "String_Node_Str"+ id+ "String_Node_Str"+ nextPathsUnsplit);
      }
      ResourceTable target=myEntityManager.find(ResourceTable.class,valueOf);
      RuntimeResourceDefinition targetResourceDef=getContext().getResourceDefinition(type);
      if (target == null) {
        String resName=targetResourceDef.getName();
        throw new InvalidRequestException("String_Node_Str" + resName + "String_Node_Str"+ id+ "String_Node_Str"+ nextPathsUnsplit);
      }
      if (!typeString.equals(target.getResourceType())) {
        throw new UnprocessableEntityException("String_Node_Str" + nextId.getValue() + "String_Node_Str"+ nextId.getIdPart()+ "String_Node_Str"+ target.getResourceType());
      }
      if (nextSpDef.getTargets() != null && !nextSpDef.getTargets().contains(typeString)) {
        continue;
      }
      ResourceLink resourceLink=new ResourceLink(nextPathAndRef.getPath(),theEntity,target,theUpdateTime);
      theLinks.add(resourceLink);
    }
  }
  theEntity.setHasLinks(theLinks.size() > 0);
  return retVal;
}