Program: 112273
Project: 112273
Buggy source:
private <R extends IBaseResource>R populateResourceMetadataRi(Class<R> theResourceType,BaseHasResource theEntity,boolean theForHistoryOperation,IAnyResource res){
  R retVal=(R)res;
  if (theEntity.getDeleted() != null) {
    res=(IAnyResource)myContext.getResourceDefinition(theResourceType).newInstance();
    retVal=(R)res;
    ResourceMetadataKeyEnum.DELETED_AT.put(res,new InstantDt(theEntity.getDeleted()));
    if (theForHistoryOperation) {
      ResourceMetadataKeyEnum.ENTRY_TRANSACTION_METHOD.put(res,HTTPVerb.DELETE.toCode());
    }
  }
 else   if (theForHistoryOperation) {
    Date published=theEntity.getPublished().getValue();
    Date updated=theEntity.getUpdated().getValue();
    if (published.equals(updated)) {
      ResourceMetadataKeyEnum.ENTRY_TRANSACTION_METHOD.put(res,HTTPVerb.POST.toCode());
    }
 else {
      ResourceMetadataKeyEnum.ENTRY_TRANSACTION_METHOD.put(res,HTTPVerb.PUT.toCode());
    }
  }
  res.getMeta().getTag().clear();
  res.getMeta().getProfile().clear();
  res.getMeta().getSecurity().clear();
  res.getMeta().setLastUpdated(null);
  res.getMeta().setVersionId(null);
  populateResourceId(res,theEntity);
  res.getMeta().setLastUpdated(theEntity.getUpdatedDate());
  IDao.RESOURCE_PID.put(res,theEntity.getId());
  Collection<? extends BaseTag> tags=theEntity.getTags();
  if (theEntity.isHasTags()) {
    for (    BaseTag next : tags) {
switch (next.getTag().getTagType()) {
case PROFILE:
        res.getMeta().addProfile(next.getTag().getCode());
      break;
case SECURITY_LABEL:
    IBaseCoding sec=res.getMeta().addSecurity();
  sec.setSystem(next.getTag().getSystem());
sec.setCode(next.getTag().getCode());
sec.setDisplay(next.getTag().getDisplay());
break;
case TAG:
IBaseCoding tag=res.getMeta().addTag();
tag.setSystem(next.getTag().getSystem());
tag.setCode(next.getTag().getCode());
tag.setDisplay(next.getTag().getDisplay());
break;
}
}
}
return retVal;
}

Fixed version (ground truth):
@SuppressWarnings("String_Node_Str") private <R extends IBaseResource>R populateResourceMetadataRi(Class<R> theResourceType,BaseHasResource theEntity,boolean theForHistoryOperation,IAnyResource res){
  R retVal=(R)res;
  if (theEntity.getDeleted() != null) {
    res=(IAnyResource)myContext.getResourceDefinition(theResourceType).newInstance();
    retVal=(R)res;
    ResourceMetadataKeyEnum.DELETED_AT.put(res,new InstantDt(theEntity.getDeleted()));
    if (theForHistoryOperation) {
      ResourceMetadataKeyEnum.ENTRY_TRANSACTION_METHOD.put(res,HTTPVerb.DELETE.toCode());
    }
  }
 else   if (theForHistoryOperation) {
    Date published=theEntity.getPublished().getValue();
    Date updated=theEntity.getUpdated().getValue();
    if (published.equals(updated)) {
      ResourceMetadataKeyEnum.ENTRY_TRANSACTION_METHOD.put(res,HTTPVerb.POST.toCode());
    }
 else {
      ResourceMetadataKeyEnum.ENTRY_TRANSACTION_METHOD.put(res,HTTPVerb.PUT.toCode());
    }
  }
  res.getMeta().getTag().clear();
  res.getMeta().getProfile().clear();
  res.getMeta().getSecurity().clear();
  res.getMeta().setLastUpdated(null);
  res.getMeta().setVersionId(null);
  populateResourceId(res,theEntity);
  res.getMeta().setLastUpdated(theEntity.getUpdatedDate());
  IDao.RESOURCE_PID.put(res,theEntity.getId());
  Collection<? extends BaseTag> tags=theEntity.getTags();
  if (theEntity.isHasTags()) {
    for (    BaseTag next : tags) {
switch (next.getTag().getTagType()) {
case PROFILE:
        res.getMeta().addProfile(next.getTag().getCode());
      break;
case SECURITY_LABEL:
    IBaseCoding sec=res.getMeta().addSecurity();
  sec.setSystem(next.getTag().getSystem());
sec.setCode(next.getTag().getCode());
sec.setDisplay(next.getTag().getDisplay());
break;
case TAG:
IBaseCoding tag=res.getMeta().addTag();
tag.setSystem(next.getTag().getSystem());
tag.setCode(next.getTag().getCode());
tag.setDisplay(next.getTag().getDisplay());
break;
}
}
}
return retVal;
}