Program: 185059
Project: 185059
Buggy source:
private WordprocessingMLPackage fetchComponents(WordprocessingMLPackage srcPackage,ContentAccessor contentAccessor) throws Docx4JException {
  Map<Integer,CTAltChunk> replacements=new HashMap<Integer,CTAltChunk>();
  Integer index=0;
  justGotAComponent=false;
  LinkedList<Integer> continuousBeforeIndex=new LinkedList<Integer>();
  List<Boolean> continuousBefore=new ArrayList<Boolean>();
  List<Boolean> continuousAfter=new ArrayList<Boolean>();
  for (  Object block : contentAccessor.getContent()) {
    if (block instanceof org.docx4j.wml.SdtBlock) {
      org.docx4j.wml.SdtBlock sdt=(org.docx4j.wml.SdtBlock)block;
      Tag tag=getSdtPr(sdt).getTag();
      if (tag == null) {
        List<Object> newContent=new ArrayList<Object>();
        newContent.add(sdt);
        continue;
      }
      log.info(tag.getVal());
      HashMap<String,String> map=QueryString.parseQueryString(tag.getVal(),true);
      String componentId=map.get(BINDING_ROLE_COMPONENT);
      if (componentId == null)       continue;
      String iri=ComponentsPart.getComponentById(components,componentId).getIri();
      log.debug("String_Node_Str" + iri);
      if (docxFetcher == null) {
        log.error("String_Node_Str");
        return srcPackage;
      }
      AlternativeFormatInputPart afiPart=new AlternativeFormatInputPart(getNewPartName("String_Node_Str","String_Node_Str",srcPackage.getMainDocumentPart().getRelationshipsPart()));
      afiPart.setBinaryData(docxFetcher.getDocxFromIRI(iri));
      afiPart.setContentType(new ContentType("String_Node_Str"));
      Relationship altChunkRel=srcPackage.getMainDocumentPart().addTargetPart(afiPart);
      CTAltChunk ac=Context.getWmlObjectFactory().createCTAltChunk();
      ac.setId(altChunkRel.getId());
      replacements.put(index,ac);
      if (map.get(BINDING_ROLE_COMPONENT_BEFORE) != null && map.get(BINDING_ROLE_COMPONENT_BEFORE).equals("String_Node_Str")) {
        continuousBefore.add(Boolean.TRUE);
        continuousBeforeIndex.addFirst(index);
        log.info("String_Node_Str" + index);
      }
 else {
        continuousBefore.add(Boolean.FALSE);
        continuousBeforeIndex.addFirst(index);
      }
      if (map.get(BINDING_ROLE_COMPONENT_AFTER) != null && map.get(BINDING_ROLE_COMPONENT_AFTER).equals("String_Node_Str")) {
        continuousAfter.add(Boolean.TRUE);
      }
 else {
        continuousAfter.add(Boolean.TRUE);
      }
      justGotAComponent=true;
    }
    index++;
  }
  if (!justGotAComponent) {
    return srcPackage;
  }
  for (  Integer key : replacements.keySet()) {
    contentAccessor.getContent().set(key,replacements.get(key));
  }
  List<Object> bodyChildren=contentAccessor.getContent();
  int i=0;
  for (  Integer indexIntoBody : continuousBeforeIndex) {
    if (continuousBefore.get(i)) {
      if (indexIntoBody == 0) {
      }
 else {
        Object block=bodyChildren.get(indexIntoBody.intValue() - 1);
        if (block instanceof P && ((P)block).getPPr() != null && ((P)block).getPPr().getSectPr() != null) {
          makeContinuous(((P)block).getPPr().getSectPr());
        }
 else         if (block instanceof P) {
          PPr ppr=((P)block).getPPr();
          if (ppr == null) {
            ppr=Context.getWmlObjectFactory().createPPr();
            ((P)block).setPPr(ppr);
          }
          SectPr newSectPr=Context.getWmlObjectFactory().createSectPr();
          SectPr.Type type=Context.getWmlObjectFactory().createSectPrType();
          type.setVal("String_Node_Str");
          newSectPr.setType(type);
          ppr.setSectPr(newSectPr);
        }
 else {
          P newP=Context.getWmlObjectFactory().createP();
          PPr ppr=Context.getWmlObjectFactory().createPPr();
          newP.setPPr(ppr);
          SectPr newSectPr=Context.getWmlObjectFactory().createSectPr();
          SectPr.Type type=Context.getWmlObjectFactory().createSectPrType();
          type.setVal("String_Node_Str");
          newSectPr.setType(type);
          ppr.setSectPr(newSectPr);
          bodyChildren.add(indexIntoBody.intValue(),newP);
        }
      }
    }
    i++;
  }
  try {
    Class<?> documentBuilder=Class.forName("String_Node_Str");
    Method[] methods=documentBuilder.getMethods();
    Method processMethod=null;
    for (int j=0; j < methods.length; j++) {
      log.debug(methods[j].getName());
      if (methods[j].getName().equals("String_Node_Str") && methods[j].getParameterCount() == 3) {
        processMethod=methods[j];
      }
    }
    if (processMethod == null)     throw new NoSuchMethodException();
    return (WordprocessingMLPackage)processMethod.invoke(null,srcPackage,xpathsMap,conditionsMap);
  }
 catch (  ClassNotFoundException e) {
    extensionMissing(e);
    justGotAComponent=false;
    return srcPackage;
  }
catch (  NoSuchMethodException e) {
    extensionMissing(e);
    justGotAComponent=false;
    return srcPackage;
  }
catch (  Exception e) {
    throw new Docx4JException("String_Node_Str",e);
  }
}

Fixed version (ground truth):
private WordprocessingMLPackage fetchComponents(WordprocessingMLPackage srcPackage,ContentAccessor contentAccessor) throws Docx4JException {
  Map<Integer,CTAltChunk> replacements=new HashMap<Integer,CTAltChunk>();
  Integer index=0;
  justGotAComponent=false;
  LinkedList<Integer> continuousBeforeIndex=new LinkedList<Integer>();
  List<Boolean> continuousBefore=new ArrayList<Boolean>();
  List<Boolean> continuousAfter=new ArrayList<Boolean>();
  for (  Object block : contentAccessor.getContent()) {
    if (block instanceof org.docx4j.wml.SdtBlock) {
      org.docx4j.wml.SdtBlock sdt=(org.docx4j.wml.SdtBlock)block;
      Tag tag=getSdtPr(sdt).getTag();
      if (tag == null) {
        List<Object> newContent=new ArrayList<Object>();
        newContent.add(sdt);
        index++;
        continue;
      }
      log.info(tag.getVal());
      HashMap<String,String> map=QueryString.parseQueryString(tag.getVal(),true);
      String componentId=map.get(BINDING_ROLE_COMPONENT);
      if (componentId == null) {
        index++;
        continue;
      }
      String iri=ComponentsPart.getComponentById(components,componentId).getIri();
      log.debug("String_Node_Str" + iri);
      if (docxFetcher == null) {
        log.error("String_Node_Str");
        return srcPackage;
      }
      AlternativeFormatInputPart afiPart=new AlternativeFormatInputPart(getNewPartName("String_Node_Str","String_Node_Str",srcPackage.getMainDocumentPart().getRelationshipsPart()));
      afiPart.setBinaryData(docxFetcher.getDocxFromIRI(iri));
      afiPart.setContentType(new ContentType("String_Node_Str"));
      Relationship altChunkRel=srcPackage.getMainDocumentPart().addTargetPart(afiPart);
      CTAltChunk ac=Context.getWmlObjectFactory().createCTAltChunk();
      ac.setId(altChunkRel.getId());
      replacements.put(index,ac);
      if (map.get(BINDING_ROLE_COMPONENT_BEFORE) != null && map.get(BINDING_ROLE_COMPONENT_BEFORE).equals("String_Node_Str")) {
        continuousBefore.add(Boolean.TRUE);
        continuousBeforeIndex.addFirst(index);
        log.info("String_Node_Str" + index);
      }
 else {
        continuousBefore.add(Boolean.FALSE);
        continuousBeforeIndex.addFirst(index);
      }
      if (map.get(BINDING_ROLE_COMPONENT_AFTER) != null && map.get(BINDING_ROLE_COMPONENT_AFTER).equals("String_Node_Str")) {
        continuousAfter.add(Boolean.TRUE);
      }
 else {
        continuousAfter.add(Boolean.TRUE);
      }
      justGotAComponent=true;
    }
    index++;
  }
  if (!justGotAComponent) {
    return srcPackage;
  }
  for (  Integer key : replacements.keySet()) {
    contentAccessor.getContent().set(key,replacements.get(key));
    System.out.println("String_Node_Str" + key);
  }
  List<Object> bodyChildren=contentAccessor.getContent();
  int i=0;
  for (  Integer indexIntoBody : continuousBeforeIndex) {
    if (continuousBefore.get(i)) {
      if (indexIntoBody == 0) {
      }
 else {
        Object block=bodyChildren.get(indexIntoBody.intValue() - 1);
        if (block instanceof P && ((P)block).getPPr() != null && ((P)block).getPPr().getSectPr() != null) {
          makeContinuous(((P)block).getPPr().getSectPr());
        }
 else         if (block instanceof P) {
          PPr ppr=((P)block).getPPr();
          if (ppr == null) {
            ppr=Context.getWmlObjectFactory().createPPr();
            ((P)block).setPPr(ppr);
          }
          SectPr newSectPr=Context.getWmlObjectFactory().createSectPr();
          SectPr.Type type=Context.getWmlObjectFactory().createSectPrType();
          type.setVal("String_Node_Str");
          newSectPr.setType(type);
          ppr.setSectPr(newSectPr);
        }
 else {
          P newP=Context.getWmlObjectFactory().createP();
          PPr ppr=Context.getWmlObjectFactory().createPPr();
          newP.setPPr(ppr);
          SectPr newSectPr=Context.getWmlObjectFactory().createSectPr();
          SectPr.Type type=Context.getWmlObjectFactory().createSectPrType();
          type.setVal("String_Node_Str");
          newSectPr.setType(type);
          ppr.setSectPr(newSectPr);
          bodyChildren.add(indexIntoBody.intValue(),newP);
        }
      }
    }
    i++;
  }
  try {
    Class<?> documentBuilder=Class.forName("String_Node_Str");
    Method[] methods=documentBuilder.getMethods();
    Method processMethod=null;
    for (int j=0; j < methods.length; j++) {
      log.debug(methods[j].getName());
      if (methods[j].getName().equals("String_Node_Str") && methods[j].getParameterCount() == 3) {
        processMethod=methods[j];
      }
    }
    if (processMethod == null)     throw new NoSuchMethodException();
    return (WordprocessingMLPackage)processMethod.invoke(null,srcPackage,xpathsMap,conditionsMap);
  }
 catch (  ClassNotFoundException e) {
    extensionMissing(e);
    justGotAComponent=false;
    return srcPackage;
  }
catch (  NoSuchMethodException e) {
    extensionMissing(e);
    justGotAComponent=false;
    return srcPackage;
  }
catch (  Exception e) {
    throw new Docx4JException("String_Node_Str",e);
  }
}