Program: 23279
Project: 23279
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.getDifferential().getElementFirstRep().getType().isEmpty())   throw new Error("String_Node_Str");
  processPaths("String_Node_Str",derived.getSnapshot(),base.getSnapshot(),derived.getDifferential(),baseCursor,diffCursor,base.getSnapshot().getElement().size() - 1,derived.getDifferential().getElement().size() - 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);
  for (  ElementDefinition e : derived.getDifferential().getElement()) {
    if (!findMatchingElement(e.getId(),derived.getSnapshot().getElement()))     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.getDifferential().getElementFirstRep().getType().isEmpty())   throw new Error("String_Node_Str");
  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);
  for (  ElementDefinition e : derived.getDifferential().getElement()) {
    if (!findMatchingElement(e.getId(),derived.getSnapshot().getElement()))     throw new DefinitionException("String_Node_Str" + derived.getUrl() + "String_Node_Str"+ e.getId());
  }
}