nus-yam/ex-repair huggingface dataset:
Program: 23278
Project: 23278
Buggy source:
public void dump() throws IOException {
  ln("String_Node_Str");
  ln_i("String_Node_Str");
  ln("String_Node_Str");
  ln("String_Node_Str");
  addNote();
  for (  Section s : sections) {
    if (s.hasContent()) {
      ln_i("String_Node_Str");
      ln("String_Node_Str" + Utilities.escapeXml(s.title) + "String_Node_Str");
      for (      Rule r : s.rules) {
        if (!r.asserts.isEmpty()) {
          ln_i("String_Node_Str" + Utilities.escapeXml(r.name) + "String_Node_Str");
          for (          Assert a : r.asserts)           ln("String_Node_Str" + Utilities.escapeXml(a.test) + "String_Node_Str"+ Utilities.escapeXml(a.message)+ "String_Node_Str");
          ln_o("String_Node_Str");
        }
      }
      ln_o("String_Node_Str");
    }
  }
  ln_o("String_Node_Str");
  flush();
  close();
}

Fixed version (ground truth):
public void dump() throws IOException {
  ln("String_Node_Str");
  ln_i("String_Node_Str");
  ln("String_Node_Str");
  ln("String_Node_Str");
  addNote();
  for (  Section s : sections) {
    if (s.hasRegularContent()) {
      ln_i("String_Node_Str");
      ln("String_Node_Str" + Utilities.escapeXml(s.title) + "String_Node_Str");
      for (      Rule r : s.getRegularRules()) {
        if (!r.asserts.isEmpty()) {
          ln_i("String_Node_Str" + Utilities.escapeXml(r.name) + "String_Node_Str");
          for (          Assert a : r.asserts)           ln("String_Node_Str" + Utilities.escapeXml(a.test) + "String_Node_Str"+ Utilities.escapeXml(a.message)+ "String_Node_Str");
          ln_o("String_Node_Str");
        }
      }
      ln_o("String_Node_Str");
    }
    if (s.hasSpecialContent()) {
      int i=1;
      for (      Rule r : s.getSpecialRules()) {
        ln_i("String_Node_Str");
        ln("String_Node_Str" + Utilities.escapeXml(s.title) + "String_Node_Str"+ i+ "String_Node_Str");
        i++;
        if (!r.asserts.isEmpty()) {
          ln_i("String_Node_Str" + Utilities.escapeXml(r.name) + "String_Node_Str");
          for (          Assert a : r.asserts)           ln("String_Node_Str" + Utilities.escapeXml(a.test) + "String_Node_Str"+ Utilities.escapeXml(a.message)+ "String_Node_Str");
          ln_o("String_Node_Str");
        }
        ln_o("String_Node_Str");
      }
    }
  }
  ln_o("String_Node_Str");
  flush();
  close();
}
Program: 23280
Project: 23280
Buggy source:
private void generateIds(List<ElementDefinition> list,String name) throws DefinitionException {
  if (list.isEmpty())   return;
  Map<String,String> idMap=new HashMap<String,String>();
  List<String> paths=new ArrayList<String>();
  for (  ElementDefinition ed : list) {
    if (!ed.hasPath())     throw new DefinitionException("String_Node_Str" + Integer.toString(list.indexOf(ed)) + "String_Node_Str"+ name);
    int depth=charCount(ed.getPath(),'.');
    String tail=tail(ed.getPath());
    while (depth < paths.size() && paths.size() > 0)     paths.remove(paths.size() - 1);
    String t=ed.hasSliceName() ? tail + "String_Node_Str" + checkName(ed.getSliceName()) : name != null ? tail + "String_Node_Str" + checkName(name) : tail;
    name=null;
    StringBuilder b=new StringBuilder();
    for (    String s : paths) {
      b.append(s);
      b.append("String_Node_Str");
    }
    b.append(t);
    String bs=b.toString();
    idMap.put(ed.hasId() ? ed.getId() : ed.getPath(),bs);
    ed.setId(bs);
    paths.add(t);
    if (ed.hasContentReference()) {
      String s=ed.getContentReference().substring(1);
      if (idMap.containsKey(s))       ed.setContentReference("String_Node_Str" + idMap.get(s));
    }
  }
}

Fixed version (ground truth):
private void generateIds(List<ElementDefinition> list,String name) throws DefinitionException {
  if (list.isEmpty())   return;
  Map<String,String> idMap=new HashMap<String,String>();
  List<String> paths=new ArrayList<String>();
  for (  ElementDefinition ed : list) {
    if (!ed.hasPath())     throw new DefinitionException("String_Node_Str" + Integer.toString(list.indexOf(ed)) + "String_Node_Str"+ name);
    int depth=charCount(ed.getPath(),'.');
    String tail=tail(ed.getPath());
    if (depth > paths.size()) {
      String[] pl=ed.getPath().split("String_Node_Str");
      for (int i=paths.size(); i < pl.length - 1; i++)       paths.add(pl[i]);
    }
    while (depth < paths.size() && paths.size() > 0)     paths.remove(paths.size() - 1);
    String t=ed.hasSliceName() ? tail + "String_Node_Str" + checkName(ed.getSliceName()) : name != null ? tail + "String_Node_Str" + checkName(name) : tail;
    name=null;
    StringBuilder b=new StringBuilder();
    for (    String s : paths) {
      b.append(s);
      b.append("String_Node_Str");
    }
    b.append(t);
    String bs=b.toString();
    idMap.put(ed.hasId() ? ed.getId() : ed.getPath(),bs);
    ed.setId(bs);
    paths.add(t);
    if (ed.hasContentReference()) {
      String s=ed.getContentReference().substring(1);
      if (idMap.containsKey(s))       ed.setContentReference("String_Node_Str" + idMap.get(s));
    }
  }
}
Program: 23282
Project: 23282
Buggy source:
private void generateZips() throws Exception {
  SpecMapManager map=new SpecMapManager(Constants.VERSION,Constants.REVISION,execTime,igpkp.getCanonical());
  for (  FetchedFile f : fileList) {
    for (    FetchedResource r : f.getResources()) {
      String u=igpkp.getCanonical() + r.getUrlTail();
      if (r.getResource() != null && r.getResource() instanceof MetadataResource) {
        String uc=((MetadataResource)r.getResource()).getUrl();
        if (uc != null && !u.equals(uc) && !u.startsWith("String_Node_Str") && !(r.getResource() instanceof CodeSystem) && !(r.getResource() instanceof ImplementationGuide))         throw new Exception("String_Node_Str" + u + "String_Node_Str"+ uc);
      }
      map.path(u,igpkp.getLinkFor(r));
    }
  }
  for (  String s : new File(outputDir).list()) {
    if (s.endsWith("String_Node_Str")) {
      map.target(s);
    }
  }
  File df=File.createTempFile("String_Node_Str","String_Node_Str");
  df.deleteOnExit();
  map.save(df.getAbsolutePath());
  if (generateExampleZip(FhirFormat.XML))   generateDefinitions(FhirFormat.XML,df.getAbsolutePath());
  if (generateExampleZip(FhirFormat.JSON))   generateDefinitions(FhirFormat.JSON,df.getAbsolutePath());
  if (generateExampleZip(FhirFormat.TURTLE))   generateDefinitions(FhirFormat.TURTLE,df.getAbsolutePath());
  generateValidationPack();
}

Fixed version (ground truth):
private void generateZips() throws Exception {
  SpecMapManager map=new SpecMapManager(Constants.VERSION,Constants.REVISION,execTime,igpkp.getCanonical());
  for (  FetchedFile f : fileList) {
    for (    FetchedResource r : f.getResources()) {
      String u=igpkp.getCanonical() + r.getUrlTail();
      if (r.getResource() != null && r.getResource() instanceof MetadataResource) {
        String uc=((MetadataResource)r.getResource()).getUrl();
        if (uc != null && !u.equals(uc) && !u.startsWith("String_Node_Str") && !(r.getResource() instanceof CodeSystem) && !(r.getResource() instanceof ImplementationGuide))         throw new Exception("String_Node_Str" + u + "String_Node_Str"+ uc);
        if (!uc.startsWith(igpkp.getCanonical()))         map.path(uc,igpkp.getLinkFor(r));
      }
      map.path(u,igpkp.getLinkFor(r));
    }
  }
  for (  String s : new File(outputDir).list()) {
    if (s.endsWith("String_Node_Str")) {
      map.target(s);
    }
  }
  File df=File.createTempFile("String_Node_Str","String_Node_Str");
  df.deleteOnExit();
  map.save(df.getAbsolutePath());
  if (generateExampleZip(FhirFormat.XML))   generateDefinitions(FhirFormat.XML,df.getAbsolutePath());
  if (generateExampleZip(FhirFormat.JSON))   generateDefinitions(FhirFormat.JSON,df.getAbsolutePath());
  if (generateExampleZip(FhirFormat.TURTLE))   generateDefinitions(FhirFormat.TURTLE,df.getAbsolutePath());
  generateValidationPack();
}
Program: 23291
Project: 23291
Buggy source:
public String content() throws EOperationOutcome, FHIRException, IOException, org.hl7.fhir.exceptions.FHIRException {
  CodeSystem csc=cs.copy();
  csc.setId(cs.getId());
  new NarrativeGenerator(prefix,prefix,context).generate(csc);
  return new XhtmlComposer().compose(csc.getText().getDiv());
}

Fixed version (ground truth):
public String content() throws EOperationOutcome, FHIRException, IOException, org.hl7.fhir.exceptions.FHIRException {
  CodeSystem csc=cs.copy();
  csc.setId(cs.getId());
  csc.setText(null);
  new NarrativeGenerator(prefix,prefix,context).generate(csc);
  return new XhtmlComposer().compose(csc.getText().getDiv());
}
Program: 23292
Project: 23292
Buggy source:
/** 
 * Converts the raw characters to XML escape characters.
 * @param rawContent
 * @param charset Null when charset is not known, so we assume it's unicode
 * @param isNoLines
 * @return escape string
 */
public static String escapeXML(String rawContent,String charset,boolean isNoLines){
  if (rawContent == null)   return "String_Node_Str";
 else {
    StringBuffer sb=new StringBuffer();
    for (int i=0; i < rawContent.length(); i++) {
      char ch=rawContent.charAt(i);
      if (ch == '\'')       sb.append("String_Node_Str");
 else       if (ch == '&')       sb.append("String_Node_Str");
 else       if (ch == '"')       sb.append("String_Node_Str");
 else       if (ch == '<')       sb.append("String_Node_Str");
 else       if (ch == '>')       sb.append("String_Node_Str");
 else       if (ch > '~' && charset != null && charSetImpliesAscii(charset))       sb.append("String_Node_Str" + Integer.toHexString(new Character(ch).hashCode()).toUpperCase() + "String_Node_Str");
 else       if (isNoLines) {
        if (ch == '\r')         sb.append("String_Node_Str");
 else         if (ch != '\n')         sb.append(ch);
      }
 else       sb.append(ch);
    }
    return sb.toString();
  }
}

Fixed version (ground truth):
/** 
 * Converts the raw characters to XML escape characters.
 * @param rawContent
 * @param charset Null when charset is not known, so we assume it's unicode
 * @param isNoLines
 * @return escape string
 */
public static String escapeXML(String rawContent,String charset,boolean isNoLines){
  if (rawContent == null)   return "String_Node_Str";
 else {
    StringBuffer sb=new StringBuffer();
    for (int i=0; i < rawContent.length(); i++) {
      char ch=rawContent.charAt(i);
      if (ch == '\'')       sb.append("String_Node_Str");
 else       if (ch == '&')       sb.append("String_Node_Str");
 else       if (ch == '"')       sb.append("String_Node_Str");
 else       if (ch == '<')       sb.append("String_Node_Str");
 else       if (ch == '>')       sb.append("String_Node_Str");
 else       if (ch > '~' && charset != null && charSetImpliesAscii(charset))       sb.append("String_Node_Str" + Integer.toHexString(ch).toUpperCase() + "String_Node_Str");
 else       if (isNoLines) {
        if (ch == '\r')         sb.append("String_Node_Str");
 else         if (ch != '\n')         sb.append(ch);
      }
 else       sb.append(ch);
    }
    return sb.toString();
  }
}
Program: 23293
Project: 23293
Buggy source:
@Override public void text(String content,boolean dontEscape) throws IOException {
  checkInElement();
  if (content != null) {
    if (pendingClose) {
      write("String_Node_Str");
      writePendingComment();
      pendingClose=false;
    }
    if (dontEscape)     write(content);
 else     write(XMLUtil.escapeXML(content,charset,false));
  }
}

Fixed version (ground truth):
@Override public void text(String content,boolean dontEscape) throws IOException {
  checkInElement();
  if (content != null) {
    if (pendingClose) {
      write("String_Node_Str");
      writePendingComment();
      pendingClose=false;
    }
    if (dontEscape)     write(content);
 else     write(XMLUtil.escapeXML(content,"String_Node_Str",false));
  }
}
Program: 23294
Project: 23294
Buggy source:
private int writeAttributeSet(boolean special,int col,int wrap) throws IOException {
  if (attributes != null) {
    for (int i=0; i < attributes.length; i++) {
      String[] element=attributes[i];
      if (nameIsSpecial(element[0]) == special) {
        col=col + element[0].length() + element[1].length()+ 4;
        if (isPretty() && attributeLineWrap > 0 && col > attributeLineWrap && col > wrap) {
          write(lineType == LINE_UNIX ? "String_Node_Str" : "String_Node_Str");
          for (int j=0; j < wrap; j++)           write("String_Node_Str");
          col=wrap;
        }
        write(' ');
        write(element[0]);
        write("String_Node_Str");
        if (element[1] != null)         write(element[1]);
        write("String_Node_Str");
      }
    }
  }
  return col;
}

Fixed version (ground truth):
private int writeAttributeSet(boolean special,int col,int wrap) throws IOException {
  if (attributes != null) {
    for (int i=0; i < attributes.length; i++) {
      String[] element=attributes[i];
      if (nameIsSpecial(element[0]) == special) {
        col=col + element[0].length() + element[1].length()+ 4;
        if (isPretty() && attributeLineWrap > 0 && col > attributeLineWrap && col > wrap) {
          write(lineType == LINE_UNIX ? "String_Node_Str" : "String_Node_Str");
          for (int j=0; j < wrap; j++)           write("String_Node_Str");
          col=wrap;
        }
        write(' ');
        write(element[0]);
        write("String_Node_Str");
        if (element[1] != null)         write(xmlEscape(element[1]));
        write("String_Node_Str");
      }
    }
  }
  return col;
}
Program: 23295
Project: 23295
Buggy source:
public boolean addProfile(List<ValidationMessage> errors,String profile,boolean error,String path,Element element){
  String effectiveProfile=profile;
  String version=null;
  if (profile.contains("String_Node_Str")) {
    effectiveProfile=profile.substring(0,profile.indexOf('|') - 1);
    version=profile.substring(profile.indexOf('|'));
  }
  StructureDefinition sd=context.fetchResource(StructureDefinition.class,effectiveProfile);
  if (warningOrError(error,errors,IssueType.INVALID,element.line(),element.col(),path,sd != null,"String_Node_Str",profile)) {
    if (rule(errors,IssueType.STRUCTURE,element.line(),element.col(),path,version == null || (sd.getVersion() != null && sd.getVersion().equals(version)),"String_Node_Str" + version + "String_Node_Str"+ sd.getVersion()+ "String_Node_Str"+ sd.getUrl(),profile)) {
      if (rule(errors,IssueType.STRUCTURE,element.line(),element.col(),path,sd.hasSnapshot(),"String_Node_Str")) {
        if (!profiles.containsKey(sd)) {
          profiles.put(sd,new ProfileUsage(sd));
          addAncestorProfiles(sd);
          return true;
        }
      }
    }
  }
  return false;
}

Fixed version (ground truth):
public boolean addProfile(List<ValidationMessage> errors,String profile,boolean error,String path,Element element){
  String effectiveProfile=profile;
  String version=null;
  if (profile.contains("String_Node_Str")) {
    effectiveProfile=profile.substring(0,profile.indexOf('|'));
    version=profile.substring(profile.indexOf('|') + 1);
  }
  StructureDefinition sd=context.fetchResource(StructureDefinition.class,effectiveProfile);
  if (warningOrError(error,errors,IssueType.INVALID,element.line(),element.col(),path,sd != null,"String_Node_Str",profile)) {
    if (rule(errors,IssueType.STRUCTURE,element.line(),element.col(),path,version == null || (sd.getVersion() != null && sd.getVersion().equals(version)),"String_Node_Str" + version + "String_Node_Str"+ sd.getVersion()+ "String_Node_Str"+ sd.getUrl(),profile)) {
      if (rule(errors,IssueType.STRUCTURE,element.line(),element.col(),path,sd.hasSnapshot(),"String_Node_Str")) {
        if (!profiles.containsKey(sd)) {
          profiles.put(sd,new ProfileUsage(sd));
          addAncestorProfiles(sd);
          return true;
        }
      }
    }
  }
  return false;
}
Program: 23303
Project: 23303
Buggy source:
private void log(String name,List<Base> contents){
  if (hostServices == null || !hostServices.Log(name,contents)) {
    if (log.length() > 0)     log.append("String_Node_Str");
    log.append(name);
    log.append("String_Node_Str");
    boolean first=true;
    for (    Base b : contents) {
      if (first)       first=false;
 else       log.append("String_Node_Str");
      log.append(convertToString(b));
    }
  }
}

Fixed version (ground truth):
private void log(String name,List<Base> contents){
  if (hostServices == null || !hostServices.log(name,contents)) {
    if (log.length() > 0)     log.append("String_Node_Str");
    log.append(name);
    log.append("String_Node_Str");
    boolean first=true;
    for (    Base b : contents) {
      if (first)       first=false;
 else       log.append("String_Node_Str");
      log.append(convertToString(b));
    }
  }
}
Program: 23304
Project: 23304
Buggy source:
private List<Base> funcResolve(ExecutionContext context,List<Base> focus,ExpressionNode exp){
  List<Base> result=new ArrayList<Base>();
  for (  Base item : focus) {
    String s=convertToString(item);
    if (hostServices != null) {
      Base res=hostServices.resolveReference(context.appInfo,s);
      if (res != null)       result.add(res);
    }
  }
  return result;
}

Fixed version (ground truth):
private List<Base> funcResolve(ExecutionContext context,List<Base> focus,ExpressionNode exp){
  List<Base> result=new ArrayList<Base>();
  for (  Base item : focus) {
    if (hostServices != null) {
      String s=convertToString(item);
      if (item.fhirType().equals("String_Node_Str")) {
        Property p=item.getChildByName("String_Node_Str");
        if (p.hasValues())         s=convertToString(p.getValues().get(0));
      }
      Base res=null;
      if (s.startsWith("String_Node_Str")) {
        String id=s.substring(1);
        Property p=context.resource.getChildByName("String_Node_Str");
        for (        Base c : p.getValues()) {
          if (id.equals(c.getIdBase()))           res=c;
        }
      }
 else       res=hostServices.resolveReference(context.appInfo,s);
      if (res != null)       result.add(res);
    }
  }
  return result;
}
Program: 23305
Project: 23305
Buggy source:
@Override public IResourceValidator makeValidator(IWorkerContext ctxts) throws FHIRException {
  return new InstanceValidator(ctxts);
}

Fixed version (ground truth):
@Override public IResourceValidator makeValidator(IWorkerContext ctxt) throws FHIRException {
  return new InstanceValidator(ctxt,null);
}
Program: 23306
Project: 23306
Buggy source:
private void validateCnt(String cnt,int errorCount,boolean json) throws Exception {
  if (TestingUtilities.context == null) {
    TestingUtilities.context=SimpleWorkerContext.fromPack(Utilities.path(TestingUtilities.home(),"String_Node_Str","String_Node_Str"));
    ((SimpleWorkerContext)TestingUtilities.context).connectToTSServer("String_Node_Str");
  }
  if (!TestingUtilities.silent)   System.out.println("String_Node_Str");
  ByteArrayInputStream file=new ByteArrayInputStream(cnt.getBytes(Charsets.UTF_8));
  InstanceValidator val=new InstanceValidator(TestingUtilities.context);
  List<ValidationMessage> errors=new ArrayList<ValidationMessage>();
  val.validate(null,errors,file,json ? FhirFormat.JSON : FhirFormat.XML);
  int ec=0;
  for (  ValidationMessage m : errors) {
    if (m.getLevel() == IssueSeverity.ERROR || m.getLevel() == IssueSeverity.FATAL) {
      ec++;
      if (!TestingUtilities.silent)       System.out.println("String_Node_Str" + m.summary());
    }
  }
  Assert.assertTrue(ec == errorCount);
  if (!TestingUtilities.silent)   System.out.println(val.reportTimes());
}

Fixed version (ground truth):
private void validateCnt(String cnt,int errorCount,boolean json) throws Exception {
  if (TestingUtilities.context == null) {
    TestingUtilities.context=SimpleWorkerContext.fromPack(Utilities.path(TestingUtilities.home(),"String_Node_Str","String_Node_Str"));
    ((SimpleWorkerContext)TestingUtilities.context).connectToTSServer("String_Node_Str");
  }
  if (!TestingUtilities.silent)   System.out.println("String_Node_Str");
  ByteArrayInputStream file=new ByteArrayInputStream(cnt.getBytes(Charsets.UTF_8));
  InstanceValidator val=new InstanceValidator(TestingUtilities.context,null);
  List<ValidationMessage> errors=new ArrayList<ValidationMessage>();
  val.validate(null,errors,file,json ? FhirFormat.JSON : FhirFormat.XML);
  int ec=0;
  for (  ValidationMessage m : errors) {
    if (m.getLevel() == IssueSeverity.ERROR || m.getLevel() == IssueSeverity.FATAL) {
      ec++;
      if (!TestingUtilities.silent)       System.out.println("String_Node_Str" + m.summary());
    }
  }
  Assert.assertTrue(ec == errorCount);
  if (!TestingUtilities.silent)   System.out.println(val.reportTimes());
}
Program: 23307
Project: 23307
Buggy source:
private void validate(String path,int errorCount,boolean json) throws Exception {
  if (TestingUtilities.context == null) {
    TestingUtilities.context=SimpleWorkerContext.fromPack(Utilities.path(TestingUtilities.home(),"String_Node_Str","String_Node_Str"));
    ((SimpleWorkerContext)TestingUtilities.context).connectToTSServer("String_Node_Str");
  }
  if (!TestingUtilities.silent)   System.out.println("String_Node_Str" + path);
  FileInputStream file=new FileInputStream(Utilities.path(TestingUtilities.home(),path));
  InstanceValidator val=new InstanceValidator(TestingUtilities.context);
  List<ValidationMessage> errors=new ArrayList<ValidationMessage>();
  val.validate(null,errors,file,json ? FhirFormat.JSON : FhirFormat.XML);
  int ec=0;
  for (  ValidationMessage m : errors) {
    if (m.getLevel() == IssueSeverity.ERROR || m.getLevel() == IssueSeverity.FATAL) {
      ec++;
      if (!TestingUtilities.silent)       System.out.println("String_Node_Str" + m.summary());
    }
  }
  Assert.assertTrue(ec == errorCount);
}

Fixed version (ground truth):
private void validate(String path,int errorCount,boolean json) throws Exception {
  if (TestingUtilities.context == null) {
    TestingUtilities.context=SimpleWorkerContext.fromPack(Utilities.path(TestingUtilities.home(),"String_Node_Str","String_Node_Str"));
    ((SimpleWorkerContext)TestingUtilities.context).connectToTSServer("String_Node_Str");
  }
  if (!TestingUtilities.silent)   System.out.println("String_Node_Str" + path);
  FileInputStream file=new FileInputStream(Utilities.path(TestingUtilities.home(),path));
  InstanceValidator val=new InstanceValidator(TestingUtilities.context,null);
  List<ValidationMessage> errors=new ArrayList<ValidationMessage>();
  val.validate(null,errors,file,json ? FhirFormat.JSON : FhirFormat.XML);
  int ec=0;
  for (  ValidationMessage m : errors) {
    if (m.getLevel() == IssueSeverity.ERROR || m.getLevel() == IssueSeverity.FATAL) {
      ec++;
      if (!TestingUtilities.silent)       System.out.println("String_Node_Str" + m.summary());
    }
  }
  Assert.assertTrue(ec == errorCount);
}
Program: 23308
Project: 23308
Buggy source:
public void execute() throws Exception {
  InstanceValidator v=new InstanceValidator(SimpleWorkerContext.fromPack(pack.getAbsolutePath()));
  Document reg=parseXml(registry.getAbsolutePath());
  List<Element> tests=new ArrayList<Element>();
  XMLUtil.getNamedChildren(reg.getDocumentElement(),"String_Node_Str",tests);
  String dir=Utilities.getDirectoryForFile(registry.getAbsolutePath()) + File.separator;
  for (  Element test : tests) {
    executeCase(v,dir,test);
  }
}

Fixed version (ground truth):
public void execute() throws Exception {
  InstanceValidator v=new InstanceValidator(SimpleWorkerContext.fromPack(pack.getAbsolutePath()),null);
  Document reg=parseXml(registry.getAbsolutePath());
  List<Element> tests=new ArrayList<Element>();
  XMLUtil.getNamedChildren(reg.getDocumentElement(),"String_Node_Str",tests);
  String dir=Utilities.getDirectoryForFile(registry.getAbsolutePath()) + File.separator;
  for (  Element test : tests) {
    executeCase(v,dir,test);
  }
}
Program: 23314
Project: 23314
Buggy source:
private List<ElementDefinition> getDiffMatches(StructureDefinitionDifferentialComponent context,String path,int start,int end,String profileName,String url) throws DefinitionException {
  List<ElementDefinition> result=new ArrayList<ElementDefinition>();
  for (int i=start; i <= end; i++) {
    String statedPath=context.getElement().get(i).getPath();
    if (statedPath.equals(path) || (path.endsWith("String_Node_Str") && statedPath.length() > path.length() - 2 && statedPath.substring(0,path.length() - 3).equals(path.substring(0,path.length() - 3)) && !statedPath.substring(path.length()).contains("String_Node_Str"))) {
      result.add(context.getElement().get(i));
    }
  }
  return result;
}

Fixed version (ground truth):
private List<ElementDefinition> getDiffMatches(StructureDefinitionDifferentialComponent context,String path,int start,int end,String profileName,String url) throws DefinitionException {
  List<ElementDefinition> result=new ArrayList<ElementDefinition>();
  for (int i=start; i <= end; i++) {
    String statedPath=context.getElement().get(i).getPath();
    if (statedPath.equals(path) || (path.endsWith("String_Node_Str") && statedPath.length() > path.length() - 2 && statedPath.substring(0,path.length() - 3).equals(path.substring(0,path.length() - 3)) && (statedPath.length() < path.length() || !statedPath.substring(path.length()).contains("String_Node_Str")))) {
      result.add(context.getElement().get(i));
    }
  }
  return result;
}
Program: 23315
Project: 23315
Buggy source:
@Override public boolean supportsSystem(String system) throws TerminologyServiceException {
  if (codeSystems.containsKey(system))   return true;
 else   if (nonSupportedCodeSystems.contains(system))   return false;
 else   if (system.startsWith("String_Node_Str") || system.startsWith("String_Node_Str") || system.startsWith("String_Node_Str")|| system.startsWith("String_Node_Str"))   return false;
 else {
    if (noTerminologyServer)     return false;
    if (bndCodeSystems == null) {
      try {
        log("String_Node_Str" + system);
        bndCodeSystems=txServer.fetchFeed(txServer.getAddress() + "String_Node_Str");
      }
 catch (      Exception e) {
        if (canRunWithoutTerminology) {
          noTerminologyServer=true;
          logger.logMessage("String_Node_Str");
          return false;
        }
 else         throw new TerminologyServiceException(e);
      }
    }
    if (bndCodeSystems != null) {
      for (      BundleEntryComponent be : bndCodeSystems.getEntry()) {
        CodeSystem cs=(CodeSystem)be.getResource();
        if (!codeSystems.containsKey(cs.getUrl())) {
          codeSystems.put(cs.getUrl(),null);
        }
      }
    }
    if (codeSystems.containsKey(system))     return true;
  }
  nonSupportedCodeSystems.add(system);
  return false;
}

Fixed version (ground truth):
@Override public boolean supportsSystem(String system) throws TerminologyServiceException {
  if (codeSystems.containsKey(system))   return true;
 else   if (nonSupportedCodeSystems.contains(system))   return false;
 else   if (system.startsWith("String_Node_Str") || system.startsWith("String_Node_Str") || system.startsWith("String_Node_Str")|| system.startsWith("String_Node_Str"))   return false;
 else {
    if (noTerminologyServer)     return false;
    if (bndCodeSystems == null) {
      try {
        log("String_Node_Str" + system);
        bndCodeSystems=txServer.fetchFeed(txServer.getAddress() + "String_Node_Str");
      }
 catch (      Exception e) {
        if (canRunWithoutTerminology) {
          noTerminologyServer=true;
          log("String_Node_Str");
          return false;
        }
 else         throw new TerminologyServiceException(e);
      }
    }
    if (bndCodeSystems != null) {
      for (      BundleEntryComponent be : bndCodeSystems.getEntry()) {
        CodeSystem cs=(CodeSystem)be.getResource();
        if (!codeSystems.containsKey(cs.getUrl())) {
          codeSystems.put(cs.getUrl(),null);
        }
      }
    }
    if (codeSystems.containsKey(system))     return true;
  }
  nonSupportedCodeSystems.add(system);
  return false;
}
Program: 23316
Project: 23316
Buggy source:
private void log(String message){
  if (logger != null)   logger.logMessage(message);
}

Fixed version (ground truth):
private void log(String message){
  if (logger != null)   logger.logMessage(message);
 else   System.out.println(message);
}
Program: 23317
Project: 23317
Buggy source:
public void setDefinitions(Definitions definitions) throws Exception {
  this.definitions=definitions;
  breadCrumbManager.setDefinitions(definitions);
  FHIRToolingClient client;
  try {
    client=new FHIRToolingClient(tsServer);
  }
 catch (  Exception e) {
    System.out.println("String_Node_Str" + e.getLocalizedMessage());
    client=null;
  }
  workerContext=new BuildWorkerContext(definitions,client,definitions.getCodeSystems(),definitions.getValuesets(),conceptMaps,profiles);
  workerContext.setDefinitions(definitions);
  workerContext.initTS(Utilities.path(folders.rootDir,"String_Node_Str"),tsServer);
  vsValidator=new ValueSetValidator(workerContext,definitions.getVsFixups(),definitions.getStyleExemptions());
  breadCrumbManager.setContext(workerContext);
}

Fixed version (ground truth):
public void setDefinitions(Definitions definitions) throws Exception {
  this.definitions=definitions;
  breadCrumbManager.setDefinitions(definitions);
  FHIRToolingClient client;
  try {
    client=new FHIRToolingClient(tsServer);
  }
 catch (  Exception e) {
    System.out.println("String_Node_Str" + e.getLocalizedMessage());
    client=null;
  }
  workerContext=new BuildWorkerContext(definitions,client,definitions.getCodeSystems(),definitions.getValuesets(),conceptMaps,profiles);
  workerContext.setDefinitions(definitions);
  workerContext.setLogger(this);
  workerContext.initTS(Utilities.path(folders.rootDir,"String_Node_Str"),tsServer);
  vsValidator=new ValueSetValidator(workerContext,definitions.getVsFixups(),definitions.getStyleExemptions());
  breadCrumbManager.setContext(workerContext);
}
Program: 23318
Project: 23318
Buggy source:
public JsonObject generate(ElementDefn root,String version,String genDate) throws Exception {
  enums.clear();
  enumDefs.clear();
  JsonObject schema=new JsonObject();
  JsonObject context=new JsonObject();
  schema.add("String_Node_Str",context);
  schema.addProperty("String_Node_Str","String_Node_Str" + root.getName());
  scanTypes(root,root);
  generateType(root,root.getName(),root,true,context);
  return schema;
}

Fixed version (ground truth):
public JsonObject generate(ElementDefn root,String version,String genDate) throws Exception {
  enums.clear();
  enumDefs.clear();
  JsonObject schema=new JsonObject();
  JsonObject context=new JsonObject();
  schema.add("String_Node_Str",context);
  scanTypes(root,root);
  generateType(root,root.getName(),root,true,context);
  return schema;
}
Program: 23320
Project: 23320
Buggy source:
private boolean runJekyll() throws IOException, InterruptedException {
  DefaultExecutor exec=new DefaultExecutor();
  exec.setExitValue(0);
  MyFilterHandler pumpHandler=new MyFilterHandler();
  PumpStreamHandler pump=new PumpStreamHandler(pumpHandler);
  exec.setStreamHandler(pump);
  exec.setWorkingDirectory(new File(tempDir));
  try {
    if (SystemUtils.IS_OS_WINDOWS)     exec.execute(org.apache.commons.exec.CommandLine.parse("String_Node_Str" + outputDir));
 else     exec.execute(org.apache.commons.exec.CommandLine.parse("String_Node_Str" + outputDir));
  }
 catch (  IOException ioex) {
    log("String_Node_Str" + pumpHandler.getBufferString());
    throw ioex;
  }
  return true;
}

Fixed version (ground truth):
private boolean runJekyll() throws IOException, InterruptedException {
  DefaultExecutor exec=new DefaultExecutor();
  exec.setExitValue(0);
  MyFilterHandler pumpHandler=new MyFilterHandler();
  PumpStreamHandler pump=new PumpStreamHandler(pumpHandler);
  exec.setStreamHandler(pump);
  exec.setWorkingDirectory(new File(tempDir));
  try {
    if (SystemUtils.IS_OS_WINDOWS)     exec.execute(org.apache.commons.exec.CommandLine.parse("String_Node_Str" + outputDir + "String_Node_Str"));
 else     exec.execute(org.apache.commons.exec.CommandLine.parse("String_Node_Str" + outputDir + "String_Node_Str"));
  }
 catch (  IOException ioex) {
    log("String_Node_Str" + pumpHandler.getBufferString());
    throw ioex;
  }
  return true;
}
Program: 23321
Project: 23321
Buggy source:
@Override public void handleCodeSystem(CodeSystem cs,ValueSet vs){
  cs.setId(vs.getId());
  cslist.add(cs);
}

Fixed version (ground truth):
@Override public void handleCodeSystem(CodeSystem cs,ValueSet vs){
  cs.setId(vs.getId());
  cs.setValueSet(vs.getUrl());
  cslist.add(cs);
}
Program: 23322
Project: 23322
Buggy source:
private ResourceWrapper fetchResource(BaseWrapper subject){
  if (resolver == null)   return null;
  String url=subject.getChildByName("String_Node_Str").value().toString();
  ResourceWithReference rr=resolver.resolve(url);
  return rr.resource;
}

Fixed version (ground truth):
private ResourceWrapper fetchResource(BaseWrapper subject){
  if (resolver == null)   return null;
  String url=subject.getChildByName("String_Node_Str").value().toString();
  ResourceWithReference rr=resolver.resolve(url);
  return rr == null ? null : rr.resource;
}
Program: 23323
Project: 23323
Buggy source:
private boolean isType(Base item,String type){
  if (item.fhirType().equals(type))   return true;
  return false;
}

Fixed version (ground truth):
private boolean isType(Base item,String type){
  if (type.equals(item.fhirType()))   return true;
  return false;
}
Program: 23326
Project: 23326
Buggy source:
private void generateZips() throws Exception {
  SpecMapManager map=new SpecMapManager(Constants.VERSION,Constants.REVISION,execTime,igpkp.getCanonical());
  for (  FetchedFile f : fileList) {
    for (    FetchedResource r : f.getResources()) {
      String u=igpkp.getCanonical() + r.getUrlTail();
      if (r.getResource() != null && r.getResource() instanceof MetadataResource) {
        String uc=((MetadataResource)r.getResource()).getUrl();
        if (uc != null && !u.equals(uc) && !u.startsWith("String_Node_Str") && !(r.getResource() instanceof CodeSystem))         throw new Exception("String_Node_Str" + u + "String_Node_Str"+ uc);
      }
      map.path(u,igpkp.getLinkFor(r));
    }
  }
  for (  String s : new File(outputDir).list()) {
    if (s.endsWith("String_Node_Str")) {
      map.target(s);
    }
  }
  File df=File.createTempFile("String_Node_Str","String_Node_Str");
  df.deleteOnExit();
  map.save(df.getAbsolutePath());
  if (generateExampleZip(FhirFormat.XML))   generateDefinitions(FhirFormat.XML,df.getAbsolutePath());
  if (generateExampleZip(FhirFormat.JSON))   generateDefinitions(FhirFormat.JSON,df.getAbsolutePath());
  if (generateExampleZip(FhirFormat.TURTLE))   generateDefinitions(FhirFormat.TURTLE,df.getAbsolutePath());
  generateValidationPack();
}

Fixed version (ground truth):
private void generateZips() throws Exception {
  SpecMapManager map=new SpecMapManager(Constants.VERSION,Constants.REVISION,execTime,igpkp.getCanonical());
  for (  FetchedFile f : fileList) {
    for (    FetchedResource r : f.getResources()) {
      String u=igpkp.getCanonical() + r.getUrlTail();
      if (r.getResource() != null && r.getResource() instanceof MetadataResource) {
        String uc=((MetadataResource)r.getResource()).getUrl();
        if (uc != null && !u.equals(uc) && !u.startsWith("String_Node_Str") && !(r.getResource() instanceof CodeSystem) && !(r.getResource() instanceof ImplementationGuide))         throw new Exception("String_Node_Str" + u + "String_Node_Str"+ uc);
      }
      map.path(u,igpkp.getLinkFor(r));
    }
  }
  for (  String s : new File(outputDir).list()) {
    if (s.endsWith("String_Node_Str")) {
      map.target(s);
    }
  }
  File df=File.createTempFile("String_Node_Str","String_Node_Str");
  df.deleteOnExit();
  map.save(df.getAbsolutePath());
  if (generateExampleZip(FhirFormat.XML))   generateDefinitions(FhirFormat.XML,df.getAbsolutePath());
  if (generateExampleZip(FhirFormat.JSON))   generateDefinitions(FhirFormat.JSON,df.getAbsolutePath());
  if (generateExampleZip(FhirFormat.TURTLE))   generateDefinitions(FhirFormat.TURTLE,df.getAbsolutePath());
  generateValidationPack();
}
Program: 23327
Project: 23327
Buggy source:
public static String readStringExtension(DomainResource c,String uri){
  Extension ex=getExtension(c,uri);
  if (ex == null)   return null;
  if ((ex.getValue() instanceof StringType))   return ((StringType)ex.getValue()).getValue();
  if ((ex.getValue() instanceof UriType))   return ((UriType)ex.getValue()).getValue();
  if (ex.getValue() instanceof CodeType)   return ((CodeType)ex.getValue()).getValue();
  if ((ex.getValue() instanceof MarkdownType))   return ((MarkdownType)ex.getValue()).getValue();
  return null;
}

Fixed version (ground truth):
public static String readStringExtension(DomainResource c,String uri){
  Extension ex=getExtension(c,uri);
  if (ex == null)   return null;
  if ((ex.getValue() instanceof StringType))   return ((StringType)ex.getValue()).getValue();
  if ((ex.getValue() instanceof UriType))   return ((UriType)ex.getValue()).getValue();
  if (ex.getValue() instanceof CodeType)   return ((CodeType)ex.getValue()).getValue();
  if (ex.getValue() instanceof IntegerType)   return ((IntegerType)ex.getValue()).asStringValue();
  if ((ex.getValue() instanceof MarkdownType))   return ((MarkdownType)ex.getValue()).getValue();
  return null;
}
Program: 23330
Project: 23330
Buggy source:
public org.hl7.fhir.dstu2.model.OperationDefinition.OperationDefinitionParameterComponent convertOperationDefinitionParameterComponent(org.hl7.fhir.dstu3.model.OperationDefinition.OperationDefinitionParameterComponent src) throws FHIRException {
  if (src == null || src.isEmpty())   return null;
  org.hl7.fhir.dstu2.model.OperationDefinition.OperationDefinitionParameterComponent tgt=new org.hl7.fhir.dstu2.model.OperationDefinition.OperationDefinitionParameterComponent();
  copyElement(src,tgt);
  tgt.setName(src.getName());
  tgt.setUse(convertOperationParameterUse(src.getUse()));
  tgt.setMin(src.getMin());
  tgt.setMax(src.getMax());
  tgt.setDocumentation(src.getDocumentation());
  if (src.hasSearchType()) {
    tgt.setType(src.getSearchType().toCode());
    tgt.setType("String_Node_Str");
  }
 else   tgt.setType(src.getType());
  tgt.setProfile(convertReference(src.getProfile()));
  tgt.setBinding(convertOperationDefinitionParameterBindingComponent(src.getBinding()));
  for (  org.hl7.fhir.dstu3.model.OperationDefinition.OperationDefinitionParameterComponent t : src.getPart())   tgt.addPart(convertOperationDefinitionParameterComponent(t));
  return tgt;
}

Fixed version (ground truth):
public org.hl7.fhir.dstu2.model.OperationDefinition.OperationDefinitionParameterComponent convertOperationDefinitionParameterComponent(org.hl7.fhir.dstu3.model.OperationDefinition.OperationDefinitionParameterComponent src) throws FHIRException {
  if (src == null || src.isEmpty())   return null;
  org.hl7.fhir.dstu2.model.OperationDefinition.OperationDefinitionParameterComponent tgt=new org.hl7.fhir.dstu2.model.OperationDefinition.OperationDefinitionParameterComponent();
  copyElement(src,tgt);
  tgt.setName(src.getName());
  tgt.setUse(convertOperationParameterUse(src.getUse()));
  tgt.setMin(src.getMin());
  tgt.setMax(src.getMax());
  tgt.setDocumentation(src.getDocumentation());
  if (src.hasSearchType()) {
    tgt.setType(src.getSearchType().toCode());
    tgt.setType("String_Node_Str");
  }
 else   tgt.setType(src.getType());
  if (src.hasProfile())   tgt.setProfile(convertReference(src.getProfile()));
  if (src.hasBinding())   tgt.setBinding(convertOperationDefinitionParameterBindingComponent(src.getBinding()));
  for (  org.hl7.fhir.dstu3.model.OperationDefinition.OperationDefinitionParameterComponent t : src.getPart())   tgt.addPart(convertOperationDefinitionParameterComponent(t));
  return tgt;
}
Program: 23332
Project: 23332
Buggy source:
public org.hl7.fhir.dstu2.model.OperationDefinition convertOperationDefinition(org.hl7.fhir.dstu3.model.OperationDefinition src) throws FHIRException {
  if (src == null || src.isEmpty())   return null;
  org.hl7.fhir.dstu2.model.OperationDefinition tgt=new org.hl7.fhir.dstu2.model.OperationDefinition();
  copyDomainResource(src,tgt);
  tgt.setUrl(src.getUrl());
  tgt.setVersion(src.getVersion());
  tgt.setName(src.getName());
  tgt.setStatus(convertConformanceResourceStatus(src.getStatus()));
  tgt.setKind(convertOperationKind(src.getKind()));
  if (src.hasExperimental())   tgt.setExperimental(src.getExperimental());
  if (src.hasDate())   tgt.setDate(src.getDate());
  tgt.setPublisher(src.getPublisher());
  for (  org.hl7.fhir.dstu3.model.ContactDetail t : src.getContact())   tgt.addContact(convertOperationDefinitionContactComponent(t));
  tgt.setDescription(src.getDescription());
  tgt.setRequirements(src.getPurpose());
  tgt.setIdempotent(src.getIdempotent());
  tgt.setCode(src.getCode());
  tgt.setNotes(src.getComment());
  tgt.setBase(convertReference(src.getBase()));
  tgt.setSystem(src.getSystem());
  if (src.getType())   for (  org.hl7.fhir.dstu3.model.CodeType t : src.getResource())   tgt.addType(t.getValue());
  tgt.setInstance(src.getInstance());
  for (  org.hl7.fhir.dstu3.model.OperationDefinition.OperationDefinitionParameterComponent t : src.getParameter())   tgt.addParameter(convertOperationDefinitionParameterComponent(t));
  return tgt;
}

Fixed version (ground truth):
public org.hl7.fhir.dstu2.model.OperationDefinition convertOperationDefinition(org.hl7.fhir.dstu3.model.OperationDefinition src) throws FHIRException {
  if (src == null || src.isEmpty())   return null;
  org.hl7.fhir.dstu2.model.OperationDefinition tgt=new org.hl7.fhir.dstu2.model.OperationDefinition();
  copyDomainResource(src,tgt);
  tgt.setUrl(src.getUrl());
  tgt.setVersion(src.getVersion());
  tgt.setName(src.getName());
  tgt.setStatus(convertConformanceResourceStatus(src.getStatus()));
  tgt.setKind(convertOperationKind(src.getKind()));
  if (src.hasExperimental())   tgt.setExperimental(src.getExperimental());
  if (src.hasDate())   tgt.setDate(src.getDate());
  tgt.setPublisher(src.getPublisher());
  for (  org.hl7.fhir.dstu3.model.ContactDetail t : src.getContact())   tgt.addContact(convertOperationDefinitionContactComponent(t));
  tgt.setDescription(src.getDescription());
  tgt.setRequirements(src.getPurpose());
  tgt.setIdempotent(src.getIdempotent());
  tgt.setCode(src.getCode());
  tgt.setNotes(src.getComment());
  if (src.hasBase())   tgt.setBase(convertReference(src.getBase()));
  tgt.setSystem(src.getSystem());
  if (src.getType())   for (  org.hl7.fhir.dstu3.model.CodeType t : src.getResource())   tgt.addType(t.getValue());
  tgt.setInstance(src.getInstance());
  for (  org.hl7.fhir.dstu3.model.OperationDefinition.OperationDefinitionParameterComponent t : src.getParameter())   tgt.addParameter(convertOperationDefinitionParameterComponent(t));
  return tgt;
}
Program: 23333
Project: 23333
Buggy source:
public org.hl7.fhir.dstu2.model.Conformance.ConformanceRestResourceComponent convertConformanceRestResourceComponent(org.hl7.fhir.dstu3.model.CapabilityStatement.CapabilityStatementRestResourceComponent src) throws FHIRException {
  if (src == null || src.isEmpty())   return null;
  org.hl7.fhir.dstu2.model.Conformance.ConformanceRestResourceComponent tgt=new org.hl7.fhir.dstu2.model.Conformance.ConformanceRestResourceComponent();
  copyElement(src,tgt);
  tgt.setType(src.getType());
  tgt.setProfile(convertReference(src.getProfile()));
  for (  org.hl7.fhir.dstu3.model.CapabilityStatement.ResourceInteractionComponent t : src.getInteraction())   tgt.addInteraction(convertResourceInteractionComponent(t));
  tgt.setVersioning(convertResourceVersionPolicy(src.getVersioning()));
  tgt.setReadHistory(src.getReadHistory());
  tgt.setUpdateCreate(src.getUpdateCreate());
  tgt.setConditionalCreate(src.getConditionalCreate());
  tgt.setConditionalUpdate(src.getConditionalUpdate());
  tgt.setConditionalDelete(convertConditionalDeleteStatus(src.getConditionalDelete()));
  for (  org.hl7.fhir.dstu3.model.StringType t : src.getSearchInclude())   tgt.addSearchInclude(t.getValue());
  for (  org.hl7.fhir.dstu3.model.StringType t : src.getSearchRevInclude())   tgt.addSearchRevInclude(t.getValue());
  for (  org.hl7.fhir.dstu3.model.CapabilityStatement.CapabilityStatementRestResourceSearchParamComponent t : src.getSearchParam())   tgt.addSearchParam(convertConformanceRestResourceSearchParamComponent(t));
  return tgt;
}

Fixed version (ground truth):
public org.hl7.fhir.dstu2.model.Conformance.ConformanceRestResourceComponent convertConformanceRestResourceComponent(org.hl7.fhir.dstu3.model.CapabilityStatement.CapabilityStatementRestResourceComponent src) throws FHIRException {
  if (src == null || src.isEmpty())   return null;
  org.hl7.fhir.dstu2.model.Conformance.ConformanceRestResourceComponent tgt=new org.hl7.fhir.dstu2.model.Conformance.ConformanceRestResourceComponent();
  copyElement(src,tgt);
  tgt.setType(src.getType());
  if (src.hasProfile())   tgt.setProfile(convertReference(src.getProfile()));
  for (  org.hl7.fhir.dstu3.model.CapabilityStatement.ResourceInteractionComponent t : src.getInteraction())   tgt.addInteraction(convertResourceInteractionComponent(t));
  tgt.setVersioning(convertResourceVersionPolicy(src.getVersioning()));
  tgt.setReadHistory(src.getReadHistory());
  tgt.setUpdateCreate(src.getUpdateCreate());
  tgt.setConditionalCreate(src.getConditionalCreate());
  tgt.setConditionalUpdate(src.getConditionalUpdate());
  tgt.setConditionalDelete(convertConditionalDeleteStatus(src.getConditionalDelete()));
  for (  org.hl7.fhir.dstu3.model.StringType t : src.getSearchInclude())   tgt.addSearchInclude(t.getValue());
  for (  org.hl7.fhir.dstu3.model.StringType t : src.getSearchRevInclude())   tgt.addSearchRevInclude(t.getValue());
  for (  org.hl7.fhir.dstu3.model.CapabilityStatement.CapabilityStatementRestResourceSearchParamComponent t : src.getSearchParam())   tgt.addSearchParam(convertConformanceRestResourceSearchParamComponent(t));
  return tgt;
}
Program: 23335
Project: 23335
Buggy source:
public org.hl7.fhir.dstu2.model.ContactPoint convertContactPoint(org.hl7.fhir.dstu3.model.ContactPoint src) throws FHIRException {
  if (src == null || src.isEmpty())   return null;
  org.hl7.fhir.dstu2.model.ContactPoint tgt=new org.hl7.fhir.dstu2.model.ContactPoint();
  copyElement(src,tgt);
  tgt.setSystem(convertContactPointSystem(src.getSystem()));
  tgt.setValue(src.getValue());
  tgt.setUse(convertContactPointUse(src.getUse()));
  tgt.setRank(src.getRank());
  tgt.setPeriod(convertPeriod(src.getPeriod()));
  return tgt;
}

Fixed version (ground truth):
public org.hl7.fhir.dstu2.model.ContactPoint convertContactPoint(org.hl7.fhir.dstu3.model.ContactPoint src) throws FHIRException {
  if (src == null || src.isEmpty())   return null;
  org.hl7.fhir.dstu2.model.ContactPoint tgt=new org.hl7.fhir.dstu2.model.ContactPoint();
  copyElement(src,tgt);
  if (src.hasSystem())   tgt.setSystem(convertContactPointSystem(src.getSystem()));
  tgt.setValue(src.getValue());
  tgt.setUse(convertContactPointUse(src.getUse()));
  tgt.setRank(src.getRank());
  if (src.hasPeriod())   tgt.setPeriod(convertPeriod(src.getPeriod()));
  return tgt;
}