Program: 23189
Project: 23189
Buggy source:
/** 
 * Given a base (snapshot) profile structure, and a differential profile, generate a new snapshot profile
 * @param base - the base structure on which the differential will be applied
 * @param differential - the differential to apply to the base
 * @param url - where the base has relative urls for profile references, these need to be converted to absolutes by prepending this URL
 * @param trimDifferential - if this is true, then the snap short generator will remove any material in the element definitions that is not different to the base
 * @return
 * @throws FHIRException 
 * @throws DefinitionException 
 * @throws Exception
 */
public void generateSnapshot(StructureDefinition base,StructureDefinition derived,String url,String profileName) throws DefinitionException, FHIRException {
  if (base == null)   throw new DefinitionException("String_Node_Str");
  if (derived == null)   throw new DefinitionException("String_Node_Str");
  if (snapshotStack.contains(derived.getUrl()))   throw new DefinitionException("String_Node_Str" + snapshotStack.toString() + "String_Node_Str");
  snapshotStack.add(derived.getUrl());
  derived.setSnapshot(new StructureDefinitionSnapshotComponent());
  int baseCursor=0;
  int diffCursor=0;
  if (derived.hasDifferential() && !derived.getDifferential().getElementFirstRep().getPath().contains("String_Node_Str") && !derived.getDifferential().getElementFirstRep().getType().isEmpty())   throw new Error("String_Node_Str");
  for (  ElementDefinition e : derived.getDifferential().getElement())   e.clearUserData(GENERATED_IN_SNAPSHOT);
  processPaths("String_Node_Str",derived.getSnapshot(),base.getSnapshot(),derived.getDifferential(),baseCursor,diffCursor,base.getSnapshot().getElement().size() - 1,derived.getDifferential().hasElement() ? derived.getDifferential().getElement().size() - 1 : -1,url,derived.getId(),null,null,false,base.getUrl(),null,false);
  if (!derived.getSnapshot().getElementFirstRep().getType().isEmpty())   throw new Error("String_Node_Str" + derived.getSnapshot().getElementFirstRep().getPath() + "String_Node_Str"+ derived.getUrl()+ "String_Node_Str"+ base.getUrl());
  updateMaps(base,derived);
  setIds(derived,false);
  if (DEBUG) {
    System.out.println("String_Node_Str");
    for (    ElementDefinition ed : derived.getDifferential().getElement())     System.out.println("String_Node_Str" + ed.getPath() + "String_Node_Str"+ typeSummaryWithProfile(ed)+ "String_Node_Str"+ ed.getMin()+ "String_Node_Str"+ ed.getMax()+ "String_Node_Str"+ sliceSummary(ed)+ "String_Node_Str"+ ed.getId()+ "String_Node_Str"+ constraintSummary(ed));
    System.out.println("String_Node_Str");
    for (    ElementDefinition ed : derived.getSnapshot().getElement())     System.out.println("String_Node_Str" + ed.getPath() + "String_Node_Str"+ typeSummaryWithProfile(ed)+ "String_Node_Str"+ ed.getMin()+ "String_Node_Str"+ ed.getMax()+ "String_Node_Str"+ sliceSummary(ed)+ "String_Node_Str"+ ed.getId()+ "String_Node_Str"+ constraintSummary(ed));
  }
  for (  ElementDefinition e : derived.getDifferential().getElement()) {
    if (!e.hasUserData(GENERATED_IN_SNAPSHOT)) {
      System.out.println("String_Node_Str" + derived.getUrl() + "String_Node_Str"+ e.getId()+ "String_Node_Str");
      throw new DefinitionException("String_Node_Str" + derived.getUrl() + "String_Node_Str"+ e.getId());
    }
  }
}

Fixed version (ground truth):
/** 
 * Given a base (snapshot) profile structure, and a differential profile, generate a new snapshot profile
 * @param base - the base structure on which the differential will be applied
 * @param differential - the differential to apply to the base
 * @param url - where the base has relative urls for profile references, these need to be converted to absolutes by prepending this URL
 * @param trimDifferential - if this is true, then the snap short generator will remove any material in the element definitions that is not different to the base
 * @return
 * @throws FHIRException 
 * @throws DefinitionException 
 * @throws Exception
 */
public void generateSnapshot(StructureDefinition base,StructureDefinition derived,String url,String profileName) throws DefinitionException, FHIRException {
  if (base == null)   throw new DefinitionException("String_Node_Str");
  if (derived == null)   throw new DefinitionException("String_Node_Str");
  if (snapshotStack.contains(derived.getUrl()))   throw new DefinitionException("String_Node_Str" + snapshotStack.toString() + "String_Node_Str");
  snapshotStack.add(derived.getUrl());
  derived.setSnapshot(new StructureDefinitionSnapshotComponent());
  int baseCursor=0;
  int diffCursor=0;
  if (derived.hasDifferential() && !derived.getDifferential().getElementFirstRep().getPath().contains("String_Node_Str") && !derived.getDifferential().getElementFirstRep().getType().isEmpty())   throw new Error("String_Node_Str");
  for (  ElementDefinition e : derived.getDifferential().getElement())   e.clearUserData(GENERATED_IN_SNAPSHOT);
  processPaths("String_Node_Str",derived.getSnapshot(),base.getSnapshot(),derived.getDifferential(),baseCursor,diffCursor,base.getSnapshot().getElement().size() - 1,derived.getDifferential().hasElement() ? derived.getDifferential().getElement().size() - 1 : -1,url,derived.getId(),null,null,false,base.getUrl(),null,false,null);
  if (!derived.getSnapshot().getElementFirstRep().getType().isEmpty())   throw new Error("String_Node_Str" + derived.getSnapshot().getElementFirstRep().getPath() + "String_Node_Str"+ derived.getUrl()+ "String_Node_Str"+ base.getUrl());
  updateMaps(base,derived);
  setIds(derived,false);
  if (DEBUG) {
    System.out.println("String_Node_Str");
    for (    ElementDefinition ed : derived.getDifferential().getElement())     System.out.println("String_Node_Str" + ed.getPath() + "String_Node_Str"+ typeSummaryWithProfile(ed)+ "String_Node_Str"+ ed.getMin()+ "String_Node_Str"+ ed.getMax()+ "String_Node_Str"+ sliceSummary(ed)+ "String_Node_Str"+ ed.getId()+ "String_Node_Str"+ constraintSummary(ed));
    System.out.println("String_Node_Str");
    for (    ElementDefinition ed : derived.getSnapshot().getElement())     System.out.println("String_Node_Str" + ed.getPath() + "String_Node_Str"+ typeSummaryWithProfile(ed)+ "String_Node_Str"+ ed.getMin()+ "String_Node_Str"+ ed.getMax()+ "String_Node_Str"+ sliceSummary(ed)+ "String_Node_Str"+ ed.getId()+ "String_Node_Str"+ constraintSummary(ed));
  }
  for (  ElementDefinition e : derived.getDifferential().getElement()) {
    if (!e.hasUserData(GENERATED_IN_SNAPSHOT)) {
      System.out.println("String_Node_Str" + derived.getUrl() + "String_Node_Str"+ e.getId()+ "String_Node_Str");
      throw new DefinitionException("String_Node_Str" + derived.getUrl() + "String_Node_Str"+ e.getId());
    }
  }
}