nus-yam/ex-repair huggingface dataset:
Program: 112279
Project: 112279
Buggy source:
@Test public void testSimpleResourceEncodeWithCustomType() throws IOException {
  FhirContext fhirCtx=new FhirContext(MyPatientWithExtensions.class);
  String xmlString=IOUtils.toString(JsonParser.class.getResourceAsStream("String_Node_Str"),Charset.forName("String_Node_Str"));
  MyPatientWithExtensions obs=fhirCtx.newXmlParser().parseResource(MyPatientWithExtensions.class,xmlString);
  assertEquals(0,obs.getAllUndeclaredExtensions().size());
  assertEquals("String_Node_Str",obs.getExtAtt().getContentType().getValue());
  assertEquals("String_Node_Str",obs.getMoreExt().getStr1().getValue());
  assertEquals("String_Node_Str",obs.getModExt().getValueAsString());
  List<ExtensionDt> undeclaredExtensions=obs.getContact().get(0).getName().getFamily().get(0).getUndeclaredExtensions();
  ExtensionDt undeclaredExtension=undeclaredExtensions.get(0);
  assertEquals("String_Node_Str",undeclaredExtension.getUrl());
  IParser jsonParser=fhirCtx.newJsonParser().setPrettyPrint(true);
  String encoded=jsonParser.encodeResourceToString(obs);
  ourLog.info(encoded);
  String jsonString=IOUtils.toString(JsonParser.class.getResourceAsStream("String_Node_Str"),Charset.forName("String_Node_Str"));
  JSON expected=JSONSerializer.toJSON(jsonString);
  JSON actual=JSONSerializer.toJSON(encoded.trim());
  String exp=expected.toString().replace("String_Node_Str","String_Node_Str");
  String act=actual.toString();
  ourLog.info("String_Node_Str",exp);
  ourLog.info("String_Node_Str",act);
  assertEquals(exp,act);
}

Fixed version (ground truth):
@Test public void testSimpleResourceEncodeWithCustomType() throws IOException {
  FhirContext fhirCtx=new FhirContext(MyPatientWithExtensions.class);
  String xmlString=IOUtils.toString(JsonParser.class.getResourceAsStream("String_Node_Str"),Charset.forName("String_Node_Str"));
  MyPatientWithExtensions obs=fhirCtx.newXmlParser().parseResource(MyPatientWithExtensions.class,xmlString);
  assertEquals(0,obs.getAllUndeclaredExtensions().size());
  assertEquals("String_Node_Str",obs.getExtAtt().getContentType().getValue());
  assertEquals("String_Node_Str",obs.getMoreExt().getStr1().getValue());
  assertEquals("String_Node_Str",obs.getModExt().getValueAsString());
  List<ExtensionDt> undeclaredExtensions=obs.getContact().get(0).getName().getFamily().get(0).getUndeclaredExtensions();
  ExtensionDt undeclaredExtension=undeclaredExtensions.get(0);
  assertEquals("String_Node_Str",undeclaredExtension.getUrl());
  IParser jsonParser=fhirCtx.newJsonParser().setPrettyPrint(true);
  String encoded=jsonParser.encodeResourceToString(obs);
  ourLog.info(encoded);
  String jsonString=IOUtils.toString(JsonParser.class.getResourceAsStream("String_Node_Str"),Charset.forName("String_Node_Str"));
  JSON expected=JSONSerializer.toJSON(jsonString);
  JSON actual=JSONSerializer.toJSON(encoded.trim());
  String exp=expected.toString().replace("String_Node_Str","String_Node_Str");
  String act=actual.toString();
  ourLog.info("String_Node_Str",exp);
  ourLog.info("String_Node_Str",act);
  assertEquals("String_Node_Str" + exp + "String_Node_Str"+ act,exp,act);
}
Program: 112280
Project: 112280
Buggy source:
@Test public void testSimpleResourceEncode() throws IOException {
  String xmlString=IOUtils.toString(JsonParser.class.getResourceAsStream("String_Node_Str"),Charset.forName("String_Node_Str"));
  Patient obs=ourCtx.newXmlParser().parseResource(Patient.class,xmlString);
  List<ExtensionDt> undeclaredExtensions=obs.getContact().get(0).getName().getFamily().get(0).getUndeclaredExtensions();
  ExtensionDt undeclaredExtension=undeclaredExtensions.get(0);
  assertEquals("String_Node_Str",undeclaredExtension.getUrl());
  assertEquals("String_Node_Str",((CodeDt)undeclaredExtension.getValue()).getValue());
  ourCtx.newJsonParser().setPrettyPrint(true).encodeResourceToWriter(obs,new OutputStreamWriter(System.out));
  IParser jsonParser=ourCtx.newJsonParser();
  String encoded=jsonParser.encodeResourceToString(obs);
  ourLog.info(encoded);
  String jsonString=IOUtils.toString(JsonParser.class.getResourceAsStream("String_Node_Str"),Charset.forName("String_Node_Str"));
  JSON expected=JSONSerializer.toJSON(jsonString);
  JSON actual=JSONSerializer.toJSON(encoded.trim());
  String exp=expected.toString().replace("String_Node_Str","String_Node_Str");
  String act=actual.toString();
  ourLog.info("String_Node_Str",exp);
  ourLog.info("String_Node_Str",act);
  assertEquals("String_Node_Str" + exp + "String_Node_Str"+ act,exp,act);
}

Fixed version (ground truth):
@Test public void testSimpleResourceEncode() throws IOException {
  String xmlString=IOUtils.toString(JsonParser.class.getResourceAsStream("String_Node_Str"),Charset.forName("String_Node_Str"));
  IParser parser=ourCtx.newXmlParser();
  parser.setParserErrorHandler(new StrictErrorHandler());
  Patient obs=parser.parseResource(Patient.class,xmlString);
  List<ExtensionDt> undeclaredExtensions=obs.getContact().get(0).getName().getFamily().get(0).getUndeclaredExtensions();
  ExtensionDt undeclaredExtension=undeclaredExtensions.get(0);
  assertEquals("String_Node_Str",undeclaredExtension.getUrl());
  assertEquals("String_Node_Str",((CodeDt)undeclaredExtension.getValue()).getValue());
  ourCtx.newJsonParser().setPrettyPrint(true).encodeResourceToWriter(obs,new OutputStreamWriter(System.out));
  IParser jsonParser=ourCtx.newJsonParser();
  String encoded=jsonParser.encodeResourceToString(obs);
  ourLog.info(encoded);
  String jsonString=IOUtils.toString(JsonParser.class.getResourceAsStream("String_Node_Str"),Charset.forName("String_Node_Str"));
  JSON expected=JSONSerializer.toJSON(jsonString);
  JSON actual=JSONSerializer.toJSON(encoded.trim());
  String exp=expected.toString().replace("String_Node_Str","String_Node_Str");
  String act=actual.toString();
  ourLog.info("String_Node_Str",exp);
  ourLog.info("String_Node_Str",act);
  assertEquals("String_Node_Str" + exp + "String_Node_Str"+ act,exp,act);
}
Program: 112283
Project: 112283
Buggy source:
@Override protected String encode(List<XMLEvent> theValue){
  try {
    StringWriter w=new StringWriter();
    XMLEventWriter ew=XmlUtil.createXmlWriter(w);
    for (    XMLEvent next : getValue()) {
      if (next.isCharacters()) {
        ew.add(next);
      }
 else {
        ew.add(next);
      }
    }
    ew.close();
    return w.toString();
  }
 catch (  XMLStreamException e) {
    throw new DataFormatException("String_Node_Str",e);
  }
catch (  FactoryConfigurationError e) {
    throw new ConfigurationException(e);
  }
}

Fixed version (ground truth):
@Override protected String encode(List<XMLEvent> theValue){
  try {
    StringWriter w=new StringWriter();
    XMLEventWriter ew=XmlUtil.createXmlFragmentWriter(w);
    for (    XMLEvent next : getValue()) {
      if (next.isCharacters()) {
        ew.add(next);
      }
 else {
        ew.add(next);
      }
    }
    ew.close();
    return w.toString();
  }
 catch (  XMLStreamException e) {
    throw new DataFormatException("String_Node_Str",e);
  }
catch (  FactoryConfigurationError e) {
    throw new ConfigurationException(e);
  }
}
Program: 112285
Project: 112285
Buggy source:
private void populateDetails(FhirContext theCtx,Throwable theException,IBaseOperationOutcome theOo){
  if (myReturnStackTracesForExceptionTypes != null) {
    for (    Class<?> next : myReturnStackTracesForExceptionTypes) {
      if (next.isAssignableFrom(theException.getClass())) {
        String detailsValue=theException.getMessage() + "String_Node_Str" + ExceptionUtils.getStackTrace(theException);
        OperationOutcomeUtil.addIssue(theCtx,theOo,"String_Node_Str",detailsValue);
        return;
      }
    }
  }
  OperationOutcomeUtil.addIssue(theCtx,theOo,"String_Node_Str",theException.getMessage());
}

Fixed version (ground truth):
private void populateDetails(FhirContext theCtx,Throwable theException,IBaseOperationOutcome theOo){
  if (myReturnStackTracesForExceptionTypes != null) {
    for (    Class<?> next : myReturnStackTracesForExceptionTypes) {
      if (next.isAssignableFrom(theException.getClass())) {
        String detailsValue=theException.getMessage() + "String_Node_Str" + ExceptionUtils.getStackTrace(theException);
        OperationOutcomeUtil.addIssue(theCtx,theOo,"String_Node_Str",detailsValue,null,PROCESSING);
        return;
      }
    }
  }
  OperationOutcomeUtil.addIssue(theCtx,theOo,"String_Node_Str",theException.getMessage(),null,PROCESSING);
}
Program: 112287
Project: 112287
Buggy source:
private MyLookup(HttpServletRequest theRequest,RequestDetails theRequestDetails){
  myRequest=theRequest;
  myRequestDetails=theRequestDetails;
}

Fixed version (ground truth):
public MyLookup(HttpServletRequest theServletRequest,BaseServerResponseException theException,RequestDetails theRequestDetails){
  myException=theException;
  myRequestDetails=theRequestDetails;
  myRequest=theServletRequest;
}
Program: 112288
Project: 112288
Buggy source:
/** 
 * Add an issue to an OperationOutcome
 * @param theCtx The fhir context
 * @param theOperationOutcome The OO resource to add to
 * @param theSeverity The severity (e.g. "error")
 * @param theDetails The details string
 */
public static void addIssue(FhirContext theCtx,IBaseOperationOutcome theOperationOutcome,String theSeverity,String theDetails,String theLocation){
  IBase issue=createIssue(theCtx,theOperationOutcome);
  populateDetails(theCtx,issue,theSeverity,theDetails,theLocation);
}

Fixed version (ground truth):
/** 
 * Add an issue to an OperationOutcome
 * @param theCtx The fhir context
 * @param theOperationOutcome The OO resource to add to
 * @param theSeverity The severity (e.g. "error")
 * @param theDetails The details string
 * @param theCode 
 */
public static void addIssue(FhirContext theCtx,IBaseOperationOutcome theOperationOutcome,String theSeverity,String theDetails,String theLocation,String theCode){
  IBase issue=createIssue(theCtx,theOperationOutcome);
  populateDetails(theCtx,issue,theSeverity,theDetails,theLocation,theCode);
}
Program: 112290
Project: 112290
Buggy source:
private void pollForNewUndeliveredResources(SubscriptionTable theSubscriptionTable){
  Subscription subscription=toResource(Subscription.class,theSubscriptionTable.getSubscriptionResource(),false);
  RuntimeResourceDefinition resourceDef=validateCriteriaAndReturnResourceDefinition(subscription);
  SearchParameterMap criteriaUrl=translateMatchUrl(subscription.getCriteria(),resourceDef);
  criteriaUrl=new SearchParameterMap();
  long start=theSubscriptionTable.getMostRecentMatch().getTime();
  long end=System.currentTimeMillis() - getConfig().getSubscriptionPollDelay();
  if (end <= start) {
    ourLog.trace("String_Node_Str");
    return;
  }
  ourLog.info("String_Node_Str",start,end);
  DateRangeParam range=new DateRangeParam();
  range.setLowerBound(new DateParam(QuantityCompararatorEnum.GREATERTHAN,start));
  range.setUpperBound(new DateParam(QuantityCompararatorEnum.LESSTHAN,end));
  criteriaUrl.setLastUpdated(range);
  IFhirResourceDao<? extends IBaseResource> dao=getDao(resourceDef.getImplementingClass());
  IBundleProvider results=dao.search(criteriaUrl);
  if (results.size() == 0) {
    return;
  }
  ourLog.info("String_Node_Str",results.size(),subscription.getId().getIdPart());
  List<SubscriptionFlaggedResource> flags=new ArrayList<SubscriptionFlaggedResource>();
  for (  IBaseResource next : results.getResources(0,results.size())) {
    SubscriptionFlaggedResource nextFlag=new SubscriptionFlaggedResource();
    nextFlag.setResource();
  }
}

Fixed version (ground truth):
private void pollForNewUndeliveredResources(SubscriptionTable theSubscriptionTable){
  Subscription subscription=toResource(Subscription.class,theSubscriptionTable.getSubscriptionResource(),false);
  RuntimeResourceDefinition resourceDef=validateCriteriaAndReturnResourceDefinition(subscription);
  SearchParameterMap criteriaUrl=translateMatchUrl(subscription.getCriteria(),resourceDef);
  criteriaUrl=new SearchParameterMap();
  long start=theSubscriptionTable.getMostRecentMatch().getTime();
  long end=System.currentTimeMillis() - getConfig().getSubscriptionPollDelay();
  if (end <= start) {
    ourLog.trace("String_Node_Str");
    return;
  }
  ourLog.info("String_Node_Str",start,end);
  DateRangeParam range=new DateRangeParam();
  range.setLowerBound(new DateParam(QuantityCompararatorEnum.GREATERTHAN,start));
  range.setUpperBound(new DateParam(QuantityCompararatorEnum.LESSTHAN,end));
  criteriaUrl.setLastUpdated(range);
  IFhirResourceDao<? extends IBaseResource> dao=getDao(resourceDef.getImplementingClass());
  IBundleProvider results=dao.search(criteriaUrl);
  if (results.size() == 0) {
    return;
  }
  ourLog.info("String_Node_Str",results.size(),subscription.getId().getIdPart());
  List<SubscriptionFlaggedResource> flags=new ArrayList<SubscriptionFlaggedResource>();
  for (  IBaseResource next : results.getResources(0,results.size())) {
    SubscriptionFlaggedResource nextFlag=new SubscriptionFlaggedResource();
  }
}
Program: 112293
Project: 112293
Buggy source:
/** 
 * <b>Not supported!</b>
 * @deprecated get/setMissing is not supported in StringDt. Use {@link TokenParam} instead if youneed this functionality
 */
@Deprecated @Override public Boolean getMissing(){
  throw new UnsupportedOperationException("String_Node_Str");
}

Fixed version (ground truth):
/** 
 * <b>Not supported!</b>
 * @deprecated get/setMissing is not supported in StringDt. Use {@link TokenParam} instead if youneed this functionality
 */
@Deprecated @Override public Boolean getMissing(){
  return null;
}
Program: 112294
Project: 112294
Buggy source:
/** 
 * <b>Not supported!</b>
 * @deprecated get/setMissing is not supported in StringDt. Use {@link QuantityParam} instead if youneed this functionality
 */
@Deprecated @Override public Boolean getMissing(){
  throw new UnsupportedOperationException("String_Node_Str");
}

Fixed version (ground truth):
/** 
 * <b>Not supported!</b>
 * @deprecated get/setMissing is not supported in StringDt. Use {@link QuantityParam} instead if youneed this functionality
 */
@Deprecated @Override public Boolean getMissing(){
  return null;
}
Program: 112295
Project: 112295
Buggy source:
/** 
 * <b>Not supported!</b>
 * @deprecated get/setMissing is not supported in StringDt. Use {@link StringParam} instead if youneed this functionality
 */
@Deprecated @Override public Boolean getMissing(){
  throw new UnsupportedOperationException("String_Node_Str");
}

Fixed version (ground truth):
/** 
 * <b>Not supported!</b>
 * @deprecated get/setMissing is not supported in StringDt. Use {@link StringParam} instead if youneed this functionality
 */
@Deprecated @Override public Boolean getMissing(){
  return null;
}
Program: 112296
Project: 112296
Buggy source:
@Override public final void setValueAsQueryToken(String theQualifier,String theValue){
  if (Constants.PARAMQUALIFIER_MISSING.equals(theQualifier)) {
    myMissing="String_Node_Str".equals(theValue);
  }
 else {
    myMissing=null;
    doSetValueAsQueryToken(theQualifier,theValue);
  }
}

Fixed version (ground truth):
@Override public final void setValueAsQueryToken(String theQualifier,String theValue){
  if (Constants.PARAMQUALIFIER_MISSING.equals(theQualifier)) {
    myMissing="String_Node_Str".equals(theValue);
    doSetValueAsQueryToken(null,null);
  }
 else {
    myMissing=null;
    doSetValueAsQueryToken(theQualifier,theValue);
  }
}
Program: 112297
Project: 112297
Buggy source:
@Override String doGetValueAsQueryToken(){
  if (super.getMissing() != null) {
    return super.getValueAsQueryToken();
  }
  StringBuilder b=new StringBuilder();
  if (myApproximate) {
    b.append('~');
  }
 else {
    b.append(defaultString(escape(myQuantity.getComparatorElement().getValue())));
  }
  if (!myQuantity.getValueElement().isEmpty()) {
    b.append(defaultString(escape(myQuantity.getValueElement().getValueAsString())));
  }
  b.append('|');
  if (!myQuantity.getSystemElement().isEmpty()) {
    b.append(defaultString(escape(myQuantity.getSystemElement().getValueAsString())));
  }
  b.append('|');
  if (!myQuantity.getUnitsElement().isEmpty()) {
    b.append(defaultString(escape(myQuantity.getUnitsElement().getValueAsString())));
  }
  return b.toString();
}

Fixed version (ground truth):
@Override String doGetValueAsQueryToken(){
  StringBuilder b=new StringBuilder();
  if (myApproximate) {
    b.append('~');
  }
 else {
    b.append(defaultString(escape(myQuantity.getComparatorElement().getValue())));
  }
  if (!myQuantity.getValueElement().isEmpty()) {
    b.append(defaultString(escape(myQuantity.getValueElement().getValueAsString())));
  }
  b.append('|');
  if (!myQuantity.getSystemElement().isEmpty()) {
    b.append(defaultString(escape(myQuantity.getSystemElement().getValueAsString())));
  }
  b.append('|');
  if (!myQuantity.getUnitsElement().isEmpty()) {
    b.append(defaultString(escape(myQuantity.getUnitsElement().getValueAsString())));
  }
  return b.toString();
}
Program: 112299
Project: 112299
Buggy source:
@Override String doGetQueryParameterQualifier(){
  return super.getQueryParameterQualifier();
}

Fixed version (ground truth):
@Override String doGetQueryParameterQualifier(){
  return null;
}
Program: 112302
Project: 112302
Buggy source:
private Set<Long> addPredicateParamMissing(Set<Long> thePids,String joinName){
  CriteriaBuilder builder=myEntityManager.getCriteriaBuilder();
  CriteriaQuery<Long> cq=builder.createQuery(Long.class);
  Root<ResourceTable> from=cq.from(ResourceTable.class);
  cq.select(from.get("String_Node_Str").as(Long.class));
  Join<Object,Object> join=from.join(joinName,JoinType.LEFT);
  if (thePids.size() > 0) {
    Predicate inPids=(from.get("String_Node_Str").in(thePids));
    cq.where(builder.and(inPids,join.isNull()));
  }
 else {
    cq.where(join.isNull());
  }
  TypedQuery<Long> q=myEntityManager.createQuery(cq);
  return new HashSet<Long>(q.getResultList());
}

Fixed version (ground truth):
private Set<Long> addPredicateParamMissing(Set<Long> thePids,String joinName,String theParamName,Class<? extends BaseResourceIndexedSearchParam> theParamTable){
  CriteriaBuilder builder=myEntityManager.getCriteriaBuilder();
  CriteriaQuery<Long> cq=builder.createQuery(Long.class);
  Root<ResourceTable> from=cq.from(ResourceTable.class);
  cq.select(from.get("String_Node_Str").as(Long.class));
  Subquery<Long> subQ=cq.subquery(Long.class);
  Root<? extends BaseResourceIndexedSearchParam> subQfrom=subQ.from(theParamTable);
  subQ.select(subQfrom.get("String_Node_Str").as(Long.class));
  subQ.where(builder.equal(subQfrom.get("String_Node_Str"),theParamName));
  Predicate joinPredicate=builder.not(builder.in(from.get("String_Node_Str")).value(subQ));
  if (thePids.size() > 0) {
    Predicate inPids=(from.get("String_Node_Str").in(thePids));
    cq.where(builder.and(inPids,joinPredicate));
  }
 else {
    cq.where(joinPredicate);
  }
  TypedQuery<Long> q=myEntityManager.createQuery(cq);
  List<Long> resultList=q.getResultList();
  HashSet<Long> retVal=new HashSet<Long>(resultList);
  return retVal;
}
Program: 112303
Project: 112303
Buggy source:
private boolean addPredicateMissingFalseIfPresentForResourceLink(String theParamName,Root<? extends ResourceLink> from,List<Predicate> codePredicates,IQueryParameterType nextOr){
  boolean missingFalse=false;
  if (nextOr.getMissing() != null) {
    if (nextOr.getMissing().booleanValue() == true) {
      throw new InvalidRequestException(getContext().getLocalizer().getMessage(BaseFhirResourceDao.class,"String_Node_Str",theParamName));
    }
    Predicate singleCode=from.get("String_Node_Str").isNotNull();
    codePredicates.add(singleCode);
    missingFalse=true;
  }
  return missingFalse;
}

Fixed version (ground truth):
private boolean addPredicateMissingFalseIfPresentForResourceLink(CriteriaBuilder theBuilder,String theParamName,Root<? extends ResourceLink> from,List<Predicate> codePredicates,IQueryParameterType nextOr){
  boolean missingFalse=false;
  if (nextOr.getMissing() != null) {
    if (nextOr.getMissing().booleanValue() == true) {
      throw new InvalidRequestException(getContext().getLocalizer().getMessage(BaseFhirResourceDao.class,"String_Node_Str",theParamName));
    }
    Predicate singleCode=from.get("String_Node_Str").isNotNull();
    Predicate name=createResourceLinkPathPredicate(theParamName,theBuilder,from);
    codePredicates.add(theBuilder.and(name,singleCode));
    missingFalse=true;
  }
  return missingFalse;
}
Program: 112305
Project: 112305
Buggy source:
private boolean addPredicateMissingFalseIfPresent(String theParamName,Root<? extends BaseResourceIndexedSearchParam> from,List<Predicate> codePredicates,IQueryParameterType nextOr){
  boolean missingFalse=false;
  if (nextOr.getMissing() != null) {
    if (nextOr.getMissing().booleanValue() == true) {
      throw new InvalidRequestException(getContext().getLocalizer().getMessage(BaseFhirResourceDao.class,"String_Node_Str",theParamName));
    }
    Predicate singleCode=from.get("String_Node_Str").isNotNull();
    codePredicates.add(singleCode);
    missingFalse=true;
  }
  return missingFalse;
}

Fixed version (ground truth):
private boolean addPredicateMissingFalseIfPresent(CriteriaBuilder theBuilder,String theParamName,Root<? extends BaseResourceIndexedSearchParam> from,List<Predicate> codePredicates,IQueryParameterType nextOr){
  boolean missingFalse=false;
  if (nextOr.getMissing() != null) {
    if (nextOr.getMissing().booleanValue() == true) {
      throw new InvalidRequestException(getContext().getLocalizer().getMessage(BaseFhirResourceDao.class,"String_Node_Str",theParamName));
    }
    Predicate singleCode=from.get("String_Node_Str").isNotNull();
    Predicate name=theBuilder.equal(from.get("String_Node_Str"),theParamName);
    codePredicates.add(theBuilder.and(name,singleCode));
    missingFalse=true;
  }
  return missingFalse;
}
Program: 112306
Project: 112306
Buggy source:
private Set<Long> addPredicateDate(String theParamName,Set<Long> thePids,List<? extends IQueryParameterType> theList){
  if (theList == null || theList.isEmpty()) {
    return thePids;
  }
  if (Boolean.TRUE.equals(theList.get(0).getMissing())) {
    return addPredicateParamMissing(thePids,"String_Node_Str");
  }
  CriteriaBuilder builder=myEntityManager.getCriteriaBuilder();
  CriteriaQuery<Long> cq=builder.createQuery(Long.class);
  Root<ResourceIndexedSearchParamDate> from=cq.from(ResourceIndexedSearchParamDate.class);
  cq.select(from.get("String_Node_Str").as(Long.class));
  List<Predicate> codePredicates=new ArrayList<Predicate>();
  for (  IQueryParameterType nextOr : theList) {
    if (addPredicateMissingFalseIfPresent(theParamName,from,codePredicates,nextOr)) {
      continue;
    }
    IQueryParameterType params=nextOr;
    Predicate p=createPredicateDate(builder,from,params);
    codePredicates.add(p);
  }
  Predicate masterCodePredicate=builder.or(codePredicates.toArray(new Predicate[0]));
  Predicate type=builder.equal(from.get("String_Node_Str"),myResourceName);
  Predicate name=builder.equal(from.get("String_Node_Str"),theParamName);
  if (thePids.size() > 0) {
    Predicate inPids=(from.get("String_Node_Str").in(thePids));
    cq.where(builder.and(type,name,masterCodePredicate,inPids));
  }
 else {
    cq.where(builder.and(type,name,masterCodePredicate));
  }
  TypedQuery<Long> q=myEntityManager.createQuery(cq);
  return new HashSet<Long>(q.getResultList());
}

Fixed version (ground truth):
private Set<Long> addPredicateDate(String theParamName,Set<Long> thePids,List<? extends IQueryParameterType> theList){
  if (theList == null || theList.isEmpty()) {
    return thePids;
  }
  if (Boolean.TRUE.equals(theList.get(0).getMissing())) {
    return addPredicateParamMissing(thePids,"String_Node_Str",theParamName,ResourceIndexedSearchParamDate.class);
  }
  CriteriaBuilder builder=myEntityManager.getCriteriaBuilder();
  CriteriaQuery<Long> cq=builder.createQuery(Long.class);
  Root<ResourceIndexedSearchParamDate> from=cq.from(ResourceIndexedSearchParamDate.class);
  cq.select(from.get("String_Node_Str").as(Long.class));
  List<Predicate> codePredicates=new ArrayList<Predicate>();
  for (  IQueryParameterType nextOr : theList) {
    if (addPredicateMissingFalseIfPresent(builder,theParamName,from,codePredicates,nextOr)) {
      continue;
    }
    IQueryParameterType params=nextOr;
    Predicate p=createPredicateDate(builder,from,params);
    codePredicates.add(p);
  }
  Predicate masterCodePredicate=builder.or(codePredicates.toArray(new Predicate[0]));
  Predicate type=builder.equal(from.get("String_Node_Str"),myResourceName);
  Predicate name=builder.equal(from.get("String_Node_Str"),theParamName);
  if (thePids.size() > 0) {
    Predicate inPids=(from.get("String_Node_Str").in(thePids));
    cq.where(builder.and(type,name,masterCodePredicate,inPids));
  }
 else {
    cq.where(builder.and(type,name,masterCodePredicate));
  }
  TypedQuery<Long> q=myEntityManager.createQuery(cq);
  return new HashSet<Long>(q.getResultList());
}
Program: 112315
Project: 112315
Buggy source:
/** 
 * Invoked prior to use to perform any initialization and make object mutable
 */
void sealAndInitialize(Map<Class<? extends IElement>,BaseRuntimeElementDefinition<?>> theClassToElementDefinitions){
  for (  BaseRuntimeChildDefinition next : myExtensions) {
    next.sealAndInitialize(theClassToElementDefinitions);
  }
  for (  RuntimeChildDeclaredExtensionDefinition next : myExtensions) {
    String extUrl=next.getExtensionUrl();
    if (myUrlToExtension.containsKey(extUrl)) {
      throw new ConfigurationException("String_Node_Str" + extUrl);
    }
 else {
      myUrlToExtension.put(extUrl,next);
    }
    if (next.isModifier()) {
      myExtensionsModifier.add(next);
    }
 else {
      myExtensionsNonModifier.add(next);
    }
  }
  myExtensions=Collections.unmodifiableList(myExtensions);
}

Fixed version (ground truth):
/** 
 * Invoked prior to use to perform any initialization and make object mutable
 */
void sealAndInitialize(Map<Class<? extends IElement>,BaseRuntimeElementDefinition<?>> theClassToElementDefinitions){
  for (  BaseRuntimeChildDefinition next : myExtensions) {
    next.sealAndInitialize(theClassToElementDefinitions);
  }
  for (  RuntimeChildDeclaredExtensionDefinition next : myExtensions) {
    String extUrl=next.getExtensionUrl();
    if (myUrlToExtension.containsKey(extUrl)) {
      throw new ConfigurationException("String_Node_Str" + extUrl + "String_Node_Str"+ getName()+ "String_Node_Str");
    }
 else {
      myUrlToExtension.put(extUrl,next);
    }
    if (next.isModifier()) {
      myExtensionsModifier.add(next);
    }
 else {
      myExtensionsNonModifier.add(next);
    }
  }
  myExtensions=Collections.unmodifiableList(myExtensions);
}
Program: 112317
Project: 112317
Buggy source:
@Override public IResource generateProfile(RuntimeResourceDefinition theRuntimeResourceDefinition){
  Profile retVal=new Profile();
  RuntimeResourceDefinition def=theRuntimeResourceDefinition;
  myId=def.getId();
  if (StringUtils.isBlank(myId)) {
    myId=theRuntimeResourceDefinition.getName().toLowerCase();
  }
  retVal.setId(new IdDt(myId));
  scanForExtensions(retVal,def);
  Collections.sort(retVal.getExtensionDefn(),new Comparator<ExtensionDefn>(){
    @Override public int compare(    ExtensionDefn theO1,    ExtensionDefn theO2){
      return theO1.getCode().compareTo(theO2.getCode());
    }
  }
);
  retVal.setName(def.getName());
  Structure struct=retVal.addStructure();
  LinkedList<String> path=new LinkedList<String>();
  StructureElement element=struct.addElement();
  element.getDefinition().setMin(1);
  element.getDefinition().setMax("String_Node_Str");
  fillProfile(struct,element,def,path,null);
  retVal.getStructure().get(0).getElement().get(0).getDefinition().addType().getCode().setValue("String_Node_Str");
  return retVal;
}

Fixed version (ground truth):
@Override public IResource generateProfile(RuntimeResourceDefinition theRuntimeResourceDefinition){
  Profile retVal=new Profile();
  RuntimeResourceDefinition def=theRuntimeResourceDefinition;
  myId=def.getId();
  if (StringUtils.isBlank(myId)) {
    myId=theRuntimeResourceDefinition.getName().toLowerCase();
  }
  retVal.setId(new IdDt(myId));
  scanForExtensions(retVal,def,new HashMap<RuntimeChildDeclaredExtensionDefinition,String>());
  Collections.sort(retVal.getExtensionDefn(),new Comparator<ExtensionDefn>(){
    @Override public int compare(    ExtensionDefn theO1,    ExtensionDefn theO2){
      return theO1.getCode().compareTo(theO2.getCode());
    }
  }
);
  retVal.setName(def.getName());
  Structure struct=retVal.addStructure();
  LinkedList<String> path=new LinkedList<String>();
  StructureElement element=struct.addElement();
  element.getDefinition().setMin(1);
  element.getDefinition().setMax("String_Node_Str");
  fillProfile(struct,element,def,path,null);
  retVal.getStructure().get(0).getElement().get(0).getDefinition().addType().getCode().setValue("String_Node_Str");
  return retVal;
}
Program: 112318
Project: 112318
Buggy source:
/** 
 * Accepts a textual DIV and parses it into XHTML events which are stored internally. <p> <b>Formatting note:</b> The text will be trimmed   {@link String#trim()}. If the text does not start with an HTML tag (generally this would be a div tag), a div tag will be automatically placed surrounding the text. </p> <p> Also note that if the parsed text contains any entities (&foo;) which are not a part of the entities defined in core XML (e.g. &sect; which is valid in XHTML 1.0 but not in XML 1.0) they will be parsed and converted to their equivalent unicode character. </p>
 */
@Override public void setValueAsString(String theValue) throws DataFormatException {
  String value=theValue.trim();
  if (value.charAt(0) != '<') {
    value="String_Node_Str" + value + "String_Node_Str";
  }
  super.setValueAsString(value);
}

Fixed version (ground truth):
/** 
 * Accepts a textual DIV and parses it into XHTML events which are stored internally. <p> <b>Formatting note:</b> The text will be trimmed   {@link String#trim()}. If the text does not start with an HTML tag (generally this would be a div tag), a div tag will be automatically placed surrounding the text. </p> <p> Also note that if the parsed text contains any entities (&foo;) which are not a part of the entities defined in core XML (e.g. &sect; which is valid in XHTML 1.0 but not in XML 1.0) they will be parsed and converted to their equivalent unicode character. </p>
 */
@Override public void setValueAsString(String theValue) throws DataFormatException {
  if (theValue == null || theValue.isEmpty()) {
    super.setValueAsString(null);
  }
 else {
    String value=theValue.trim();
    if (value.charAt(0) != '<') {
      value="String_Node_Str" + value + "String_Node_Str";
    }
    super.setValueAsString(value);
  }
}
Program: 112319
Project: 112319
Buggy source:
@Test public void testProfileWithBoundCode() throws IOException {
  String content=IOUtils.toString(XmlParserTest.class.getResourceAsStream("String_Node_Str"));
  ourCtx.newXmlParser().parseResource(Profile.class,content);
}

Fixed version (ground truth):
@Test public void testProfileWithBoundCode() throws IOException {
  String content=IOUtils.toString(XmlParserTest.class.getResourceAsStream("String_Node_Str"),"String_Node_Str");
  ourCtx.newXmlParser().parseResource(Profile.class,content);
}
Program: 112320
Project: 112320
Buggy source:
public static HttpPutClientInvocation createUpdateInvocation(IResource theResource,String theResourceBody,IdDt theId,FhirContext theContext){
  String resourceName=theContext.getResourceDefinition(theResource).getName();
  StringBuilder urlBuilder=new StringBuilder();
  urlBuilder.append(resourceName);
  urlBuilder.append('/');
  urlBuilder.append(theId.getIdPart());
  HttpPutClientInvocation retVal;
  String urlExtension=urlBuilder.toString();
  if (StringUtils.isBlank(theResourceBody)) {
    retVal=new HttpPutClientInvocation(theContext,theResource,urlExtension);
  }
 else {
    retVal=new HttpPutClientInvocation(theContext,theResourceBody,false,urlExtension);
  }
  if (theId.hasVersionIdPart()) {
    String versionId=theId.getVersionIdPart();
    if (StringUtils.isNotBlank(versionId)) {
      urlBuilder.append('/');
      urlBuilder.append(Constants.PARAM_HISTORY);
      urlBuilder.append('/');
      urlBuilder.append(versionId);
      retVal.addHeader(Constants.HEADER_CONTENT_LOCATION,urlBuilder.toString());
    }
  }
  addTagsToPostOrPut(theResource,retVal);
  return retVal;
}

Fixed version (ground truth):
public static HttpPutClientInvocation createUpdateInvocation(IResource theResource,String theResourceBody,IdDt theId,FhirContext theContext){
  String resourceName=theContext.getResourceDefinition(theResource).getName();
  StringBuilder urlBuilder=new StringBuilder();
  urlBuilder.append(resourceName);
  urlBuilder.append('/');
  urlBuilder.append(theId.getIdPart());
  HttpPutClientInvocation retVal;
  String urlExtension=urlBuilder.toString();
  if (StringUtils.isBlank(theResourceBody)) {
    retVal=new HttpPutClientInvocation(theContext,theResource,urlExtension);
  }
 else {
    retVal=new HttpPutClientInvocation(theContext,theResourceBody,false,urlExtension);
  }
  if (theId.hasVersionIdPart()) {
    String versionId=theId.getVersionIdPart();
    if (StringUtils.isNotBlank(versionId)) {
      urlBuilder.append('/');
      urlBuilder.append(Constants.PARAM_HISTORY);
      urlBuilder.append('/');
      urlBuilder.append(versionId);
      retVal.addHeader(Constants.HEADER_CONTENT_LOCATION,urlBuilder.toString());
    }
  }
  addTagsToPostOrPut(theResource,retVal);
  addContentTypeHeaderBasedOnDetectedType(retVal,theResourceBody);
  return retVal;
}
Program: 112321
Project: 112321
Buggy source:
public static HttpPostClientInvocation createCreateInvocation(IResource theResource,String theResourceBody,String theId,FhirContext theContext){
  RuntimeResourceDefinition def=theContext.getResourceDefinition(theResource);
  String resourceName=def.getName();
  StringBuilder urlExtension=new StringBuilder();
  urlExtension.append(resourceName);
  if (StringUtils.isNotBlank(theId)) {
    urlExtension.append('/');
    urlExtension.append(theId);
  }
  HttpPostClientInvocation retVal;
  if (StringUtils.isBlank(theResourceBody)) {
    retVal=new HttpPostClientInvocation(theContext,theResource,urlExtension.toString());
  }
 else {
    retVal=new HttpPostClientInvocation(theContext,theResourceBody,false,urlExtension.toString());
  }
  addTagsToPostOrPut(theResource,retVal);
  return retVal;
}

Fixed version (ground truth):
public static HttpPostClientInvocation createCreateInvocation(IResource theResource,String theResourceBody,String theId,FhirContext theContext){
  RuntimeResourceDefinition def=theContext.getResourceDefinition(theResource);
  String resourceName=def.getName();
  StringBuilder urlExtension=new StringBuilder();
  urlExtension.append(resourceName);
  if (StringUtils.isNotBlank(theId)) {
    urlExtension.append('/');
    urlExtension.append(theId);
  }
  HttpPostClientInvocation retVal;
  if (StringUtils.isBlank(theResourceBody)) {
    retVal=new HttpPostClientInvocation(theContext,theResource,urlExtension.toString());
  }
 else {
    retVal=new HttpPostClientInvocation(theContext,theResourceBody,false,urlExtension.toString());
  }
  addTagsToPostOrPut(theResource,retVal);
  addContentTypeHeaderBasedOnDetectedType(retVal,theResourceBody);
  return retVal;
}
Program: 112328
Project: 112328
Buggy source:
/** 
 * Returns the scanned runtime model for the given type. This is an advanced feature which is generally only needed for extending the core library.
 */
@SuppressWarnings("String_Node_Str") public RuntimeResourceDefinition getResourceDefinition(String theResourceName){
  String resourceName=theResourceName;
  if (Character.isLowerCase(resourceName.charAt(0))) {
    resourceName=WordUtils.capitalize(resourceName);
  }
  Validate.notBlank(resourceName,"String_Node_Str");
  RuntimeResourceDefinition retVal=myNameToElementDefinition.get(resourceName);
  if (retVal == null) {
    try {
      String className=myNameToResourceType.get(resourceName.toLowerCase());
      if (className == null) {
        throw new DataFormatException("String_Node_Str" + resourceName + "String_Node_Str");
      }
      Class<?> clazz=Class.forName(className);
      if (IResource.class.isAssignableFrom(clazz)) {
        retVal=scanResourceType((Class<? extends IResource>)clazz);
      }
    }
 catch (    ClassNotFoundException e) {
      throw new DataFormatException("String_Node_Str" + resourceName + "String_Node_Str");
    }
  }
  return retVal;
}

Fixed version (ground truth):
/** 
 * Returns the scanned runtime model for the given type. This is an advanced feature which is generally only needed for extending the core library.
 */
@SuppressWarnings("String_Node_Str") public RuntimeResourceDefinition getResourceDefinition(String theResourceName){
  String resourceName=theResourceName;
  if (Character.isLowerCase(resourceName.charAt(0))) {
    resourceName=WordUtils.capitalize(resourceName);
  }
  Validate.notBlank(resourceName,"String_Node_Str");
  RuntimeResourceDefinition retVal=myNameToElementDefinition.get(resourceName);
  if (retVal == null) {
    try {
      String className=myNameToResourceType.get(resourceName.toLowerCase());
      if (className == null) {
        if ("String_Node_Str".equals(resourceName.toLowerCase())) {
          className=Binary.class.getName();
        }
 else {
          throw new DataFormatException("String_Node_Str" + resourceName + "String_Node_Str");
        }
      }
      Class<?> clazz=Class.forName(className);
      if (IResource.class.isAssignableFrom(clazz)) {
        retVal=scanResourceType((Class<? extends IResource>)clazz);
      }
    }
 catch (    ClassNotFoundException e) {
      throw new DataFormatException("String_Node_Str" + resourceName + "String_Node_Str");
    }
  }
  return retVal;
}
Program: 112334
Project: 112334
Buggy source:
public ResourceIndexedSearchParamDate(String theName,Date theLow,Date theHigh){
  setName(theName);
  setValueLow(theLow);
  setValueHigh(theHigh);
}

Fixed version (ground truth):
public ResourceIndexedSearchParamDate(String theName,Date theLow,Date theHigh){
  setParamName(theName);
  setValueLow(theLow);
  setValueHigh(theHigh);
}
Program: 112335
Project: 112335
Buggy source:
public ResourceIndexedSearchParamNumber(String theParamName,BigDecimal theValue,String theSystem,String theUnits){
  setName(theParamName);
  setSystem(theSystem);
  setValue(theValue);
  setUnits(theUnits);
}

Fixed version (ground truth):
public ResourceIndexedSearchParamNumber(String theParamName,BigDecimal theValue,String theSystem,String theUnits){
  setParamName(theParamName);
  setSystem(theSystem);
  setValue(theValue);
  setUnits(theUnits);
}
Program: 112336
Project: 112336
Buggy source:
public ResourceIndexedSearchParamString(String theName,String theValueNormalized,String theValueExact){
  setName(theName);
  setValueNormalized(theValueNormalized);
  setValueExact(theValueExact);
}

Fixed version (ground truth):
public ResourceIndexedSearchParamString(String theName,String theValueNormalized,String theValueExact){
  setParamName(theName);
  setValueNormalized(theValueNormalized);
  setValueExact(theValueExact);
}
Program: 112337
Project: 112337
Buggy source:
public ResourceIndexedSearchParamToken(String theName,String theSystem,String theValue){
  setName(theName);
  setSystem(theSystem);
  setValue(theValue);
}

Fixed version (ground truth):
public ResourceIndexedSearchParamToken(String theName,String theSystem,String theValue){
  setParamName(theName);
  setSystem(theSystem);
  setValue(theValue);
}
Program: 112338
Project: 112338
Buggy source:
@Test public void testSearchStringParamWithNonNormalized(){
{
    Patient patient=new Patient();
    patient.addIdentifier("String_Node_Str","String_Node_Str");
    patient.addName().addGiven("String_Node_Str");
    ourPatientDao.create(patient);
  }
{
    Patient patient=new Patient();
    patient.addIdentifier("String_Node_Str","String_Node_Str");
    patient.addName().addGiven("String_Node_Str");
    ourPatientDao.create(patient);
  }
  Map<String,IQueryParameterType> params=new HashMap<String,IQueryParameterType>();
  params.put(Patient.SP_FAMILY,new StringDt("String_Node_Str"));
  List<Patient> patients=ourPatientDao.search(params);
  assertEquals(2,patients.size());
  StringParam parameter=new StringParam("String_Node_Str");
  parameter.setExact(true);
  params.put(Patient.SP_FAMILY,parameter);
  patients=ourPatientDao.search(params);
  assertEquals(0,patients.size());
}

Fixed version (ground truth):
@Test public void testSearchStringParamWithNonNormalized(){
{
    Patient patient=new Patient();
    patient.addIdentifier("String_Node_Str","String_Node_Str");
    patient.addName().addGiven("String_Node_Str");
    ourPatientDao.create(patient);
  }
{
    Patient patient=new Patient();
    patient.addIdentifier("String_Node_Str","String_Node_Str");
    patient.addName().addGiven("String_Node_Str");
    ourPatientDao.create(patient);
  }
  Map<String,IQueryParameterType> params=new HashMap<String,IQueryParameterType>();
  params.put(Patient.SP_GIVEN,new StringDt("String_Node_Str"));
  List<Patient> patients=ourPatientDao.search(params);
  assertEquals(2,patients.size());
  StringParam parameter=new StringParam("String_Node_Str");
  parameter.setExact(true);
  params.put(Patient.SP_GIVEN,parameter);
  patients=ourPatientDao.search(params);
  assertEquals(0,patients.size());
}
Program: 112339
Project: 112339
Buggy source:
@Test public void testPersistSearchParamDate(){
  Patient patient=new Patient();
  patient.addIdentifier("String_Node_Str","String_Node_Str");
  patient.setBirthDate(new DateTimeDt("String_Node_Str"));
  ourPatientDao.create(patient);
  List<Patient> found=ourPatientDao.search("String_Node_Str",new QualifiedDateParam(QuantityCompararatorEnum.GREATERTHAN,"String_Node_Str"));
  assertEquals(1,found.size());
}

Fixed version (ground truth):
@Test public void testPersistSearchParamDate(){
  Patient patient=new Patient();
  patient.addIdentifier("String_Node_Str","String_Node_Str");
  patient.setBirthDate(new DateTimeDt("String_Node_Str"));
  ourPatientDao.create(patient);
  List<Patient> found=ourPatientDao.search(Patient.SP_BIRTHDATE,new QualifiedDateParam(QuantityCompararatorEnum.GREATERTHAN,"String_Node_Str"));
  assertEquals(1,found.size());
  found=ourPatientDao.search(Patient.SP_BIRTHDATE + "String_Node_Str",new QualifiedDateParam(QuantityCompararatorEnum.GREATERTHAN,"String_Node_Str"));
  assertEquals(0,found.size());
}
Program: 112341
Project: 112341
Buggy source:
@Test public void testSearchNameParam(){
  IdDt id1;
{
    Patient patient=new Patient();
    patient.addIdentifier("String_Node_Str","String_Node_Str");
    patient.addName().addFamily("String_Node_Str").addGiven("String_Node_Str");
    id1=ourPatientDao.create(patient).getId();
  }
{
    Patient patient=new Patient();
    patient.addIdentifier("String_Node_Str","String_Node_Str");
    patient.addName().addFamily("String_Node_Str").addGiven("String_Node_Str");
    ourPatientDao.create(patient);
  }
  Map<String,IQueryParameterType> params=new HashMap<String,IQueryParameterType>();
  params.put(Patient.SP_FAMILY,new StringDt("String_Node_Str"));
  List<Patient> patients=ourPatientDao.search(params);
  assertEquals(1,patients.size());
  assertEquals(id1.getUnqualifiedId(),patients.get(0).getId().getUnqualifiedId());
  params=new HashMap<String,IQueryParameterType>();
  params.put(Patient.SP_FAMILY,new StringDt("String_Node_Str"));
  patients=ourPatientDao.search(params);
  assertEquals(1,patients.size());
  assertEquals(id1.getUnqualifiedId(),patients.get(0).getId().getUnqualifiedId());
  params=new HashMap<String,IQueryParameterType>();
  params.put(Patient.SP_FAMILY,new StringDt("String_Node_Str"));
  patients=ourPatientDao.search(params);
  assertEquals(0,patients.size());
}

Fixed version (ground truth):
@Test public void testSearchNameParam(){
  IdDt id1;
{
    Patient patient=new Patient();
    patient.addIdentifier("String_Node_Str","String_Node_Str");
    patient.addName().addFamily("String_Node_Str").addGiven("String_Node_Str");
    id1=ourPatientDao.create(patient).getId();
  }
{
    Patient patient=new Patient();
    patient.addIdentifier("String_Node_Str","String_Node_Str");
    patient.addName().addFamily("String_Node_Str").addGiven("String_Node_Str");
    ourPatientDao.create(patient);
  }
  Map<String,IQueryParameterType> params=new HashMap<String,IQueryParameterType>();
  params.put(Patient.SP_FAMILY,new StringDt("String_Node_Str"));
  List<Patient> patients=ourPatientDao.search(params);
  assertEquals(1,patients.size());
  assertEquals(id1.getUnqualifiedId(),patients.get(0).getId().getUnqualifiedId());
  params=new HashMap<String,IQueryParameterType>();
  params.put(Patient.SP_FAMILY,new StringDt("String_Node_Str"));
  patients=ourPatientDao.search(params);
  assertEquals(0,patients.size());
  params=new HashMap<String,IQueryParameterType>();
  params.put(Patient.SP_NAME,new StringDt("String_Node_Str"));
  patients=ourPatientDao.search(params);
  assertEquals(1,patients.size());
  assertEquals(id1.getUnqualifiedId(),patients.get(0).getId().getUnqualifiedId());
  params=new HashMap<String,IQueryParameterType>();
  params.put(Patient.SP_NAME,new StringDt("String_Node_Str"));
  patients=ourPatientDao.search(params);
  assertEquals(1,patients.size());
  assertEquals(id1.getUnqualifiedId(),patients.get(0).getId().getUnqualifiedId());
  params=new HashMap<String,IQueryParameterType>();
  params.put(Patient.SP_FAMILY,new StringDt("String_Node_Str"));
  patients=ourPatientDao.search(params);
  assertEquals(0,patients.size());
}
Program: 112342
Project: 112342
Buggy source:
private void writeUndeclaredExt(RuntimeResourceDefinition theResDef,IResource theResource,JsonGenerator theEventWriter,ExtensionDt ext) throws IOException {
  theEventWriter.writeStartObject();
  theEventWriter.write("String_Node_Str",ext.getUrl().getValue());
  IElement value=ext.getValue();
  if (value == null && ext.getAllUndeclaredExtensions().isEmpty()) {
    theEventWriter.writeNull();
  }
 else   if (value == null) {
    theEventWriter.writeStartArray("String_Node_Str");
    for (    ExtensionDt next : ext.getUndeclaredExtensions()) {
      writeUndeclaredExt(theResDef,theResource,theEventWriter,next);
    }
    theEventWriter.writeEnd();
  }
 else {
    RuntimeChildUndeclaredExtensionDefinition extDef=myContext.getRuntimeChildUndeclaredExtensionDefinition();
    String childName=extDef.getChildNameByDatatype(value.getClass());
    if (childName == null) {
      throw new ConfigurationException("String_Node_Str" + value.getClass().getCanonicalName());
    }
    BaseRuntimeElementDefinition<?> childDef=extDef.getChildElementDefinitionByDatatype(value.getClass());
    encodeChildElementToStreamWriter(theResDef,theResource,theEventWriter,value,childDef,childName);
  }
  theEventWriter.writeEnd();
}

Fixed version (ground truth):
private void writeUndeclaredExt(RuntimeResourceDefinition theResDef,IResource theResource,JsonGenerator theEventWriter,ExtensionDt ext) throws IOException {
  IElement value=ext.getValue();
  theEventWriter.writeStartObject();
  theEventWriter.write("String_Node_Str",ext.getUrl().getValue());
  if (value == null && ext.getAllUndeclaredExtensions().isEmpty()) {
    ourLog.debug("String_Node_Str",ext.getUrl().getValue());
  }
 else   if (value == null) {
    theEventWriter.writeStartArray("String_Node_Str");
    for (    ExtensionDt next : ext.getUndeclaredExtensions()) {
      writeUndeclaredExt(theResDef,theResource,theEventWriter,next);
    }
    theEventWriter.writeEnd();
  }
 else {
    RuntimeChildUndeclaredExtensionDefinition extDef=myContext.getRuntimeChildUndeclaredExtensionDefinition();
    String childName=extDef.getChildNameByDatatype(value.getClass());
    if (childName == null) {
      throw new ConfigurationException("String_Node_Str" + value.getClass().getCanonicalName());
    }
    BaseRuntimeElementDefinition<?> childDef=extDef.getChildElementDefinitionByDatatype(value.getClass());
    encodeChildElementToStreamWriter(theResDef,theResource,theEventWriter,value,childDef,childName);
  }
  theEventWriter.writeEnd();
}