Program: 23349
Project: 23349
Buggy source:
private int processExtension(Sheet sheet,int row,String uri,List<ValidationMessage> issues,Map<String,ElementDefinitionConstraintComponent> invariants) throws Exception {
  String name=sheet.getColumn(row,"String_Node_Str");
  StructureDefinition ex=new StructureDefinition();
  ex.setUrl(uri + name);
  ex.setId(tail(ex.getUrl()));
  bundle.addEntry().setResource(ex).setFullUrl(ex.getUrl());
  ex.setKind(StructureDefinitionKind.COMPLEXTYPE);
  ex.setType("String_Node_Str");
  ex.setBaseDefinition("String_Node_Str");
  ex.setDerivation(TypeDerivationRule.CONSTRAINT);
  ex.setAbstract(false);
  ex.setFhirVersion(Constants.VERSION);
  String context=null;
  if (Utilities.noString(name))   throw new Exception("String_Node_Str" + getLocation(row));
  if (name.contains("String_Node_Str"))   throw new Exception("String_Node_Str" + name + "String_Node_Str"+ getLocation(row));
  if (context == null) {
    ex.setContextType(readContextType(sheet.getColumn(row,"String_Node_Str"),row));
    if (sheet.hasColumn("String_Node_Str"))     for (    String s : sheet.getColumn(row,"String_Node_Str").split("String_Node_Str"))     ex.addContextInvariant(s);
    String cc=sheet.getColumn(row,"String_Node_Str");
    if (!Utilities.noString(cc))     for (    String c : cc.split("String_Node_Str")) {
      checkContextValid(ex.getContextType(),c,this.name);
      ex.addContext(c);
    }
  }
  ex.setTitle(sheet.getColumn(row,"String_Node_Str"));
  ElementDefinition exe=ex.getDifferential().addElement();
  exe.setPath("String_Node_Str");
  exe.setSliceName(sheet.getColumn(row,"String_Node_Str"));
  ElementDefinition exu=ex.getDifferential().addElement();
  exu.setPath("String_Node_Str");
  exu.setFixed(new UriType(ex.getUrl()));
  if (invariants != null) {
    for (    ElementDefinitionConstraintComponent inv : invariants.values()) {
      if (inv.getKey().equals(name))       exe.getConstraint().add(inv);
    }
  }
  parseExtensionElement(sheet,row,ex,exe,false);
  String sl=exe.getShort();
  ex.setName(sheet.getColumn(row,"String_Node_Str"));
  if (!ex.hasName())   ex.setName(ex.getTitle());
  if (!Utilities.noString(sl) && (!sl.contains("String_Node_Str") || !ex.hasName()))   ex.setName(sl);
  if (!ex.hasName())   throw new Exception("String_Node_Str" + ex.getUrl() + "String_Node_Str"+ getLocation(row));
  ex.setDescription(exe.getDefinition());
  ex.setPublisher(metadata("String_Node_Str"));
  if (hasMetadata("String_Node_Str"))   ex.addContact().getTelecom().add(Factory.newContactPoint(ContactPointSystem.OTHER,metadata("String_Node_Str")));
  if (hasMetadata("String_Node_Str"))   ex.setDateElement(Factory.newDateTime(metadata("String_Node_Str").substring(0,10)));
 else   ex.setDate(genDate.getTime());
  if (hasMetadata("String_Node_Str"))   ex.setStatus(PublicationStatus.fromCode(metadata("String_Node_Str")));
  row++;
  while (row < sheet.getRows().size() && sheet.getColumn(row,"String_Node_Str").startsWith(name + "String_Node_Str")) {
    String n=sheet.getColumn(row,"String_Node_Str");
    ElementDefinition child=ex.getDifferential().addElement();
    child.setPath("String_Node_Str");
    child.setSliceName(n.substring(n.lastIndexOf("String_Node_Str") + 1));
    parseExtensionElement(sheet,row,ex,child,true);
    if (invariants != null) {
      for (      ElementDefinitionConstraintComponent inv : invariants.values()) {
        if (inv.getKey().equals(n))         child.getConstraint().add(inv);
      }
    }
    row++;
  }
  ex.getDifferential().getElementFirstRep().getType().clear();
  if (ex.getDifferential().getElementFirstRep().hasRequirements()) {
    ex.setPurpose(ex.getDifferential().getElementFirstRep().getRequirements());
    ex.getDifferential().getElementFirstRep().setRequirements(null);
  }
  if (ex.getDifferential().getElementFirstRep().hasLabel()) {
    ex.setTitle(ex.getDifferential().getElementFirstRep().getLabel());
    ex.getDifferential().getElementFirstRep().setLabel(null);
  }
  if (ex.getDifferential().getElementFirstRep().hasCode()) {
    ex.getKeyword().addAll(ex.getDifferential().getElementFirstRep().getCode());
    ex.getDifferential().getElementFirstRep().getCode().clear();
  }
  StructureDefinition base=this.context.fetchResource(StructureDefinition.class,"String_Node_Str");
  List<String> errors=new ArrayList<String>();
  ProfileUtilities utils=new ProfileUtilities(this.context,issues,null);
  utils.sortDifferential(base,ex,"String_Node_Str" + ex.getUrl(),errors);
  assert(errors.size() == 0);
  utils.setIds(ex,false);
  return row;
}

Fixed version (ground truth):
private int processExtension(Sheet sheet,int row,String uri,List<ValidationMessage> issues,Map<String,ElementDefinitionConstraintComponent> invariants) throws Exception {
  String name=sheet.getColumn(row,"String_Node_Str");
  StructureDefinition ex=new StructureDefinition();
  ex.setUrl(uri + name);
  ex.setId(tail(ex.getUrl()));
  bundle.addEntry().setResource(ex).setFullUrl(ex.getUrl());
  ex.setKind(StructureDefinitionKind.COMPLEXTYPE);
  ex.setType("String_Node_Str");
  ex.setBaseDefinition("String_Node_Str");
  ex.setDerivation(TypeDerivationRule.CONSTRAINT);
  ex.setAbstract(false);
  ex.setFhirVersion(Constants.VERSION);
  String context=null;
  if (Utilities.noString(name))   throw new Exception("String_Node_Str" + getLocation(row));
  if (name.contains("String_Node_Str"))   throw new Exception("String_Node_Str" + name + "String_Node_Str"+ getLocation(row));
  if (context == null) {
    ex.setContextType(readContextType(sheet.getColumn(row,"String_Node_Str"),row));
    if (sheet.hasColumn("String_Node_Str"))     for (    String s : sheet.getColumn(row,"String_Node_Str").split("String_Node_Str"))     ex.addContextInvariant(s);
    String cc=sheet.getColumn(row,"String_Node_Str");
    if (!Utilities.noString(cc))     for (    String c : cc.split("String_Node_Str")) {
      checkContextValid(ex.getContextType(),c,this.name);
      ex.addContext(c);
    }
  }
  ex.setTitle(sheet.getColumn(row,"String_Node_Str"));
  ElementDefinition exe=ex.getDifferential().addElement();
  exe.setPath("String_Node_Str");
  exe.setSliceName(sheet.getColumn(row,"String_Node_Str"));
  ElementDefinition exu=ex.getDifferential().addElement();
  exu.setPath("String_Node_Str");
  exu.setFixed(new UriType(ex.getUrl()));
  if (invariants != null) {
    for (    ElementDefinitionConstraintComponent inv : invariants.values()) {
      if (inv.getKey().equals(name))       exe.getConstraint().add(inv);
    }
  }
  parseExtensionElement(sheet,row,ex,exe,false);
  String sl=exe.getShort();
  ex.setName(sheet.getColumn(row,"String_Node_Str"));
  if (!ex.hasName())   ex.setName(ex.getTitle());
  if (!Utilities.noString(sl) && (!sl.contains("String_Node_Str") || !ex.hasName()))   ex.setName(sl);
  if (!ex.hasName())   throw new Exception("String_Node_Str" + ex.getUrl() + "String_Node_Str"+ getLocation(row));
  ex.setDescription(exe.getDefinition());
  ex.setPublisher(metadata("String_Node_Str"));
  if (hasMetadata("String_Node_Str"))   ex.addContact().getTelecom().add(Factory.newContactPoint(ContactPointSystem.OTHER,metadata("String_Node_Str")));
  if (hasMetadata("String_Node_Str"))   ex.setDateElement(Factory.newDateTime(metadata("String_Node_Str").substring(0,10)));
 else   ex.setDate(genDate.getTime());
  if (hasMetadata("String_Node_Str"))   ex.setStatus(PublicationStatus.fromCode(metadata("String_Node_Str")));
  row++;
  boolean hasChild=false;
  while (row < sheet.getRows().size() && sheet.getColumn(row,"String_Node_Str").startsWith(name + "String_Node_Str")) {
    hasChild=true;
    String n=sheet.getColumn(row,"String_Node_Str");
    ElementDefinition child=ex.getDifferential().addElement();
    child.setPath("String_Node_Str");
    child.setSliceName(n.substring(n.lastIndexOf("String_Node_Str") + 1));
    parseExtensionElement(sheet,row,ex,child,true);
    if (invariants != null) {
      for (      ElementDefinitionConstraintComponent inv : invariants.values()) {
        if (inv.getKey().equals(n))         child.getConstraint().add(inv);
      }
    }
    row++;
  }
  if (hasChild) {
    boolean found=false;
    for (    ElementDefinition exv : ex.getDifferential().getElement())     if (exv.getPath().startsWith("String_Node_Str")) {
      found=true;
      exv.setMax("String_Node_Str");
    }
    if (!found) {
      ex.getDifferential().addElement().setPath("String_Node_Str").setMax("String_Node_Str");
    }
  }
  ex.getDifferential().getElementFirstRep().getType().clear();
  if (ex.getDifferential().getElementFirstRep().hasRequirements()) {
    ex.setPurpose(ex.getDifferential().getElementFirstRep().getRequirements());
    ex.getDifferential().getElementFirstRep().setRequirements(null);
  }
  if (ex.getDifferential().getElementFirstRep().hasLabel()) {
    ex.setTitle(ex.getDifferential().getElementFirstRep().getLabel());
    ex.getDifferential().getElementFirstRep().setLabel(null);
  }
  if (ex.getDifferential().getElementFirstRep().hasCode()) {
    ex.getKeyword().addAll(ex.getDifferential().getElementFirstRep().getCode());
    ex.getDifferential().getElementFirstRep().getCode().clear();
  }
  StructureDefinition base=this.context.fetchResource(StructureDefinition.class,"String_Node_Str");
  List<String> errors=new ArrayList<String>();
  ProfileUtilities utils=new ProfileUtilities(this.context,issues,null);
  utils.sortDifferential(base,ex,"String_Node_Str" + ex.getUrl(),errors);
  assert(errors.size() == 0);
  utils.setIds(ex,false);
  return row;
}