Program: 112309
Project: 112309
Buggy source:
private void encodeBundleToWriterInDstu2Format(Bundle theBundle,JsonGenerator theEventWriter) throws IOException {
  theEventWriter.writeStartObject();
  theEventWriter.write("String_Node_Str","String_Node_Str");
  writeOptionalTagWithTextNode(theEventWriter,"String_Node_Str",theBundle.getId().getIdPart());
  if (!ElementUtil.isEmpty(theBundle.getId().getVersionIdPart(),theBundle.getUpdated())) {
    theEventWriter.writeStartObject("String_Node_Str");
    writeOptionalTagWithTextNode(theEventWriter,"String_Node_Str",theBundle.getId().getVersionIdPart());
    writeOptionalTagWithTextNode(theEventWriter,"String_Node_Str",theBundle.getUpdated());
    theEventWriter.writeEnd();
  }
  writeOptionalTagWithTextNode(theEventWriter,"String_Node_Str",theBundle.getType());
  writeOptionalTagWithTextNode(theEventWriter,"String_Node_Str",theBundle.getLinkBase());
  writeOptionalTagWithNumberNode(theEventWriter,"String_Node_Str",theBundle.getTotalResults());
  boolean linkStarted=false;
  linkStarted=writeAtomLinkInDstu2Format(theEventWriter,"String_Node_Str",theBundle.getLinkNext(),linkStarted);
  linkStarted=writeAtomLinkInDstu2Format(theEventWriter,"String_Node_Str",theBundle.getLinkSelf(),linkStarted);
  linkStarted=writeAtomLinkInDstu2Format(theEventWriter,"String_Node_Str",theBundle.getLinkFirst(),linkStarted);
  linkStarted=writeAtomLinkInDstu2Format(theEventWriter,"String_Node_Str",theBundle.getLinkPrevious(),linkStarted);
  linkStarted=writeAtomLinkInDstu2Format(theEventWriter,"String_Node_Str",theBundle.getLinkLast(),linkStarted);
  if (linkStarted) {
    theEventWriter.writeEnd();
  }
  theEventWriter.writeStartArray("String_Node_Str");
  for (  BundleEntry nextEntry : theBundle.getEntries()) {
    theEventWriter.writeStartObject();
    writeOptionalTagWithTextNode(theEventWriter,"String_Node_Str",determineResourceBaseUrl(theBundle.getLinkBase().getValue(),nextEntry));
    boolean deleted=nextEntry.getDeletedAt() != null && nextEntry.getDeletedAt().isEmpty() == false;
    IResource resource=nextEntry.getResource();
    if (resource != null && !resource.isEmpty() && !deleted) {
      RuntimeResourceDefinition resDef=myContext.getResourceDefinition(resource);
      encodeResourceToJsonStreamWriter(resDef,resource,theEventWriter,"String_Node_Str",false);
    }
    if (nextEntry.getSearchMode().isEmpty() == false || nextEntry.getScore().isEmpty() == false) {
      theEventWriter.writeStartObject("String_Node_Str");
      writeOptionalTagWithTextNode(theEventWriter,"String_Node_Str",nextEntry.getSearchMode().getValueAsString());
      writeOptionalTagWithDecimalNode(theEventWriter,"String_Node_Str",nextEntry.getScore());
      theEventWriter.writeEnd();
    }
    if (nextEntry.getTransactionOperation().isEmpty() == false || nextEntry.getLinkSearch().isEmpty() == false) {
      theEventWriter.writeStartObject("String_Node_Str");
      writeOptionalTagWithTextNode(theEventWriter,"String_Node_Str",nextEntry.getTransactionOperation().getValue());
      writeOptionalTagWithTextNode(theEventWriter,"String_Node_Str",nextEntry.getLinkSearch().getValue());
      theEventWriter.writeEnd();
    }
    if (deleted) {
      theEventWriter.writeStartObject("String_Node_Str");
      if (nextEntry.getResource() != null) {
        theEventWriter.write("String_Node_Str",myContext.getResourceDefinition(nextEntry.getResource()).getName());
        writeOptionalTagWithTextNode(theEventWriter,"String_Node_Str",nextEntry.getResource().getId().getIdPart());
        writeOptionalTagWithTextNode(theEventWriter,"String_Node_Str",nextEntry.getResource().getId().getVersionIdPart());
      }
      writeTagWithTextNode(theEventWriter,"String_Node_Str",nextEntry.getDeletedAt());
      theEventWriter.writeEnd();
    }
    if (nextEntry.getSummary().isEmpty() == false) {
      theEventWriter.write("String_Node_Str",nextEntry.getSummary().getValueAsString());
    }
    theEventWriter.writeEnd();
  }
  theEventWriter.writeEnd();
  theEventWriter.writeEnd();
}

Fixed version (ground truth):
private void encodeBundleToWriterInDstu2Format(Bundle theBundle,JsonGenerator theEventWriter) throws IOException {
  theEventWriter.writeStartObject();
  theEventWriter.write("String_Node_Str","String_Node_Str");
  writeOptionalTagWithTextNode(theEventWriter,"String_Node_Str",theBundle.getId().getIdPart());
  if (!ElementUtil.isEmpty(theBundle.getId().getVersionIdPart(),theBundle.getUpdated())) {
    theEventWriter.writeStartObject("String_Node_Str");
    writeOptionalTagWithTextNode(theEventWriter,"String_Node_Str",theBundle.getId().getVersionIdPart());
    writeOptionalTagWithTextNode(theEventWriter,"String_Node_Str",theBundle.getUpdated());
    theEventWriter.writeEnd();
  }
  writeOptionalTagWithTextNode(theEventWriter,"String_Node_Str",theBundle.getType());
  writeOptionalTagWithTextNode(theEventWriter,"String_Node_Str",theBundle.getLinkBase());
  writeOptionalTagWithNumberNode(theEventWriter,"String_Node_Str",theBundle.getTotalResults());
  boolean linkStarted=false;
  linkStarted=writeAtomLinkInDstu2Format(theEventWriter,"String_Node_Str",theBundle.getLinkNext(),linkStarted);
  linkStarted=writeAtomLinkInDstu2Format(theEventWriter,"String_Node_Str",theBundle.getLinkSelf(),linkStarted);
  linkStarted=writeAtomLinkInDstu2Format(theEventWriter,"String_Node_Str",theBundle.getLinkFirst(),linkStarted);
  linkStarted=writeAtomLinkInDstu2Format(theEventWriter,"String_Node_Str",theBundle.getLinkPrevious(),linkStarted);
  linkStarted=writeAtomLinkInDstu2Format(theEventWriter,"String_Node_Str",theBundle.getLinkLast(),linkStarted);
  if (linkStarted) {
    theEventWriter.writeEnd();
  }
  theEventWriter.writeStartArray("String_Node_Str");
  for (  BundleEntry nextEntry : theBundle.getEntries()) {
    theEventWriter.writeStartObject();
    writeOptionalTagWithTextNode(theEventWriter,"String_Node_Str",determineResourceBaseUrl(theBundle.getLinkBase().getValue(),nextEntry));
    boolean deleted=nextEntry.getDeletedAt() != null && nextEntry.getDeletedAt().isEmpty() == false;
    IResource resource=nextEntry.getResource();
    if (resource != null && !resource.isEmpty() && !deleted) {
      RuntimeResourceDefinition resDef=myContext.getResourceDefinition(resource);
      encodeResourceToJsonStreamWriter(resDef,resource,theEventWriter,"String_Node_Str",false);
    }
    if (nextEntry.getSearchMode().isEmpty() == false || nextEntry.getScore().isEmpty() == false) {
      theEventWriter.writeStartObject("String_Node_Str");
      writeOptionalTagWithTextNode(theEventWriter,"String_Node_Str",nextEntry.getSearchMode().getValueAsString());
      writeOptionalTagWithDecimalNode(theEventWriter,"String_Node_Str",nextEntry.getScore());
      theEventWriter.writeEnd();
    }
    if (nextEntry.getTransactionMethod().isEmpty() == false || nextEntry.getLinkSearch().isEmpty() == false) {
      theEventWriter.writeStartObject("String_Node_Str");
      writeOptionalTagWithTextNode(theEventWriter,"String_Node_Str",nextEntry.getTransactionMethod().getValue());
      writeOptionalTagWithTextNode(theEventWriter,"String_Node_Str",nextEntry.getLinkSearch().getValue());
      theEventWriter.writeEnd();
    }
    if (deleted) {
      theEventWriter.writeStartObject("String_Node_Str");
      if (nextEntry.getResource() != null) {
        theEventWriter.write("String_Node_Str",myContext.getResourceDefinition(nextEntry.getResource()).getName());
        writeOptionalTagWithTextNode(theEventWriter,"String_Node_Str",nextEntry.getResource().getId().getIdPart());
        writeOptionalTagWithTextNode(theEventWriter,"String_Node_Str",nextEntry.getResource().getId().getVersionIdPart());
      }
      writeTagWithTextNode(theEventWriter,"String_Node_Str",nextEntry.getDeletedAt());
      theEventWriter.writeEnd();
    }
    if (nextEntry.getSummary().isEmpty() == false) {
      theEventWriter.write("String_Node_Str",nextEntry.getSummary().getValueAsString());
    }
    theEventWriter.writeEnd();
  }
  theEventWriter.writeEnd();
  theEventWriter.writeEnd();
}