Program: 112308
Project: 112308
Buggy source:
/** 
 * Creates a new entry using the given resource and populates it accordingly
 * @param theResource The resource to add
 * @return Returns the newly created bundle entry that was added to the bundle
 */
public BundleEntry addResource(IResource theResource,FhirContext theContext,String theServerBase){
  BundleEntry entry=addEntry();
  entry.setResource(theResource);
  RuntimeResourceDefinition def=theContext.getResourceDefinition(theResource);
  String title=ResourceMetadataKeyEnum.TITLE.get(theResource);
  if (title != null) {
    entry.getTitle().setValue(title);
  }
 else {
    entry.getTitle().setValue(def.getName() + "String_Node_Str" + StringUtils.defaultString(theResource.getId().getValue(),"String_Node_Str"));
  }
  if (theResource.getId() != null) {
    if (theResource.getId().isAbsolute()) {
      entry.getLinkSelf().setValue(theResource.getId().getValue());
      entry.getId().setValue(theResource.getId().toVersionless().getValue());
    }
 else     if (StringUtils.isNotBlank(theResource.getId().getValue())) {
      StringBuilder b=new StringBuilder();
      b.append(theServerBase);
      if (b.length() > 0 && b.charAt(b.length() - 1) != '/') {
        b.append('/');
      }
      b.append(def.getName());
      b.append('/');
      String resId=theResource.getId().getIdPart();
      b.append(resId);
      entry.getId().setValue(b.toString());
      if (isNotBlank(theResource.getId().getVersionIdPart())) {
        b.append('/');
        b.append(Constants.PARAM_HISTORY);
        b.append('/');
        b.append(theResource.getId().getVersionIdPart());
      }
 else {
        IdDt versionId=(IdDt)ResourceMetadataKeyEnum.VERSION_ID.get(theResource);
        if (versionId != null) {
          b.append('/');
          b.append(Constants.PARAM_HISTORY);
          b.append('/');
          b.append(versionId.getValue());
        }
      }
      String qualifiedId=b.toString();
      entry.getLinkSelf().setValue(qualifiedId);
    }
  }
  InstantDt published=ResourceMetadataKeyEnum.PUBLISHED.get(theResource);
  if (published == null) {
    entry.getPublished().setToCurrentTimeInLocalTimeZone();
  }
 else {
    entry.setPublished(published);
  }
  InstantDt updated=ResourceMetadataKeyEnum.UPDATED.get(theResource);
  if (updated != null) {
    entry.setUpdated(updated);
  }
  InstantDt deleted=ResourceMetadataKeyEnum.DELETED_AT.get(theResource);
  if (deleted != null) {
    entry.setDeleted(deleted);
  }
  IdDt previous=ResourceMetadataKeyEnum.PREVIOUS_ID.get(theResource);
  if (previous != null) {
    entry.getLinkAlternate().setValue(previous.withServerBase(theServerBase,def.getName()).getValue());
  }
  TagList tagList=ResourceMetadataKeyEnum.TAG_LIST.get(theResource);
  if (tagList != null) {
    for (    Tag nextTag : tagList) {
      entry.addCategory(nextTag);
    }
  }
  String linkSearch=ResourceMetadataKeyEnum.LINK_SEARCH.get(theResource);
  if (isNotBlank(linkSearch)) {
    if (!UrlUtil.isAbsolute(linkSearch)) {
      linkSearch=(theServerBase + "String_Node_Str" + linkSearch);
    }
    entry.getLinkSearch().setValue(linkSearch);
  }
  String linkAlternate=ResourceMetadataKeyEnum.LINK_ALTERNATE.get(theResource);
  if (isNotBlank(linkAlternate)) {
    if (!UrlUtil.isAbsolute(linkAlternate)) {
      linkSearch=(theServerBase + "String_Node_Str" + linkAlternate);
    }
    entry.getLinkAlternate().setValue(linkSearch);
  }
  BundleEntrySearchModeEnum entryStatus=ResourceMetadataKeyEnum.ENTRY_SEARCH_MODE.get(theResource);
  if (entryStatus != null) {
    entry.getSearchMode().setValueAsEnum(entryStatus);
  }
  BundleEntryTransactionOperationEnum entryTransactionOperation=ResourceMetadataKeyEnum.ENTRY_TRANSACTION_OPERATION.get(theResource);
  if (entryTransactionOperation != null) {
    entry.getTransactionOperation().setValueAsEnum(entryTransactionOperation);
  }
  DecimalDt entryScore=ResourceMetadataKeyEnum.ENTRY_SCORE.get(theResource);
  if (entryScore != null) {
    entry.setScore(entryScore);
  }
  return entry;
}

Fixed version (ground truth):
/** 
 * Creates a new entry using the given resource and populates it accordingly
 * @param theResource The resource to add
 * @return Returns the newly created bundle entry that was added to the bundle
 */
public BundleEntry addResource(IResource theResource,FhirContext theContext,String theServerBase){
  BundleEntry entry=addEntry();
  entry.setResource(theResource);
  RuntimeResourceDefinition def=theContext.getResourceDefinition(theResource);
  String title=ResourceMetadataKeyEnum.TITLE.get(theResource);
  if (title != null) {
    entry.getTitle().setValue(title);
  }
 else {
    entry.getTitle().setValue(def.getName() + "String_Node_Str" + StringUtils.defaultString(theResource.getId().getValue(),"String_Node_Str"));
  }
  if (theResource.getId() != null) {
    if (theResource.getId().isAbsolute()) {
      entry.getLinkSelf().setValue(theResource.getId().getValue());
      entry.getId().setValue(theResource.getId().toVersionless().getValue());
    }
 else     if (StringUtils.isNotBlank(theResource.getId().getValue())) {
      StringBuilder b=new StringBuilder();
      b.append(theServerBase);
      if (b.length() > 0 && b.charAt(b.length() - 1) != '/') {
        b.append('/');
      }
      b.append(def.getName());
      b.append('/');
      String resId=theResource.getId().getIdPart();
      b.append(resId);
      entry.getId().setValue(b.toString());
      if (isNotBlank(theResource.getId().getVersionIdPart())) {
        b.append('/');
        b.append(Constants.PARAM_HISTORY);
        b.append('/');
        b.append(theResource.getId().getVersionIdPart());
      }
 else {
        IdDt versionId=(IdDt)ResourceMetadataKeyEnum.VERSION_ID.get(theResource);
        if (versionId != null) {
          b.append('/');
          b.append(Constants.PARAM_HISTORY);
          b.append('/');
          b.append(versionId.getValue());
        }
      }
      String qualifiedId=b.toString();
      entry.getLinkSelf().setValue(qualifiedId);
    }
  }
  InstantDt published=ResourceMetadataKeyEnum.PUBLISHED.get(theResource);
  if (published == null) {
    entry.getPublished().setToCurrentTimeInLocalTimeZone();
  }
 else {
    entry.setPublished(published);
  }
  InstantDt updated=ResourceMetadataKeyEnum.UPDATED.get(theResource);
  if (updated != null) {
    entry.setUpdated(updated);
  }
  InstantDt deleted=ResourceMetadataKeyEnum.DELETED_AT.get(theResource);
  if (deleted != null) {
    entry.setDeleted(deleted);
  }
  IdDt previous=ResourceMetadataKeyEnum.PREVIOUS_ID.get(theResource);
  if (previous != null) {
    entry.getLinkAlternate().setValue(previous.withServerBase(theServerBase,def.getName()).getValue());
  }
  TagList tagList=ResourceMetadataKeyEnum.TAG_LIST.get(theResource);
  if (tagList != null) {
    for (    Tag nextTag : tagList) {
      entry.addCategory(nextTag);
    }
  }
  String linkSearch=ResourceMetadataKeyEnum.LINK_SEARCH.get(theResource);
  if (isNotBlank(linkSearch)) {
    if (!UrlUtil.isAbsolute(linkSearch)) {
      linkSearch=(theServerBase + "String_Node_Str" + linkSearch);
    }
    entry.getLinkSearch().setValue(linkSearch);
  }
  String linkAlternate=ResourceMetadataKeyEnum.LINK_ALTERNATE.get(theResource);
  if (isNotBlank(linkAlternate)) {
    if (!UrlUtil.isAbsolute(linkAlternate)) {
      linkSearch=(theServerBase + "String_Node_Str" + linkAlternate);
    }
    entry.getLinkAlternate().setValue(linkSearch);
  }
  BundleEntrySearchModeEnum entryStatus=ResourceMetadataKeyEnum.ENTRY_SEARCH_MODE.get(theResource);
  if (entryStatus != null) {
    entry.getSearchMode().setValueAsEnum(entryStatus);
  }
  BundleEntryTransactionMethodEnum entryTransactionOperation=ResourceMetadataKeyEnum.ENTRY_TRANSACTION_METHOD.get(theResource);
  if (entryTransactionOperation != null) {
    entry.getTransactionMethod().setValueAsEnum(entryTransactionOperation);
  }
  DecimalDt entryScore=ResourceMetadataKeyEnum.ENTRY_SCORE.get(theResource);
  if (entryScore != null) {
    entry.setScore(entryScore);
  }
  return entry;
}