Program: 185072
Project: 185072
Buggy source:
/** 
 * Inject the calculated heights for each header and footer, and adjust the region body margins to fit them.
 * @param layoutMasterSet
 * @param headerBpda
 * @param footerBpda
 */
static void adjustLayoutMasterSet(LayoutMasterSet layoutMasterSet,ConversionSectionWrappers conversionSectionWrappers,Map<String,Integer> headerBpda,Map<String,Integer> footerBpda){
  List<ConversionSectionWrapper> sections=conversionSectionWrappers.getList();
  ConversionSectionWrapper section=null;
  for (  Object o : layoutMasterSet.getSimplePageMasterOrPageSequenceMaster()) {
    if (o instanceof SimplePageMaster) {
      SimplePageMaster spm=((SimplePageMaster)o);
      String simplePageMasterName=spm.getMasterName();
      int index=-1 + Integer.parseInt(simplePageMasterName.substring(1,simplePageMasterName.indexOf("String_Node_Str")));
      PageDimensions page=null;
      if (sections.get(index) == null) {
        log.error("String_Node_Str" + index + "String_Node_Str"+ simplePageMasterName);
      }
 else {
        page=sections.get(index).getPageDimensions();
      }
      if (spm.getRegionBefore() != null) {
        Integer hBpdaMilliPts=headerBpda.get(simplePageMasterName);
        if (hBpdaMilliPts == null) {
          log.error("String_Node_Str" + simplePageMasterName);
        }
 else {
          float hBpdaPts=hBpdaMilliPts / 1000;
          spm.getRegionBefore().setExtent(hBpdaPts + "String_Node_Str");
          spm.getRegionBody().setMarginTop(hBpdaPts + "String_Node_Str");
          float totalHeight=(page.getHeaderMargin() / 20) + hBpdaPts;
          float extraMargin=(page.getPgMar().getTop().intValue() / 20) - totalHeight;
          if (extraMargin > 0) {
            float required=(page.getPgMar().getTop().intValue() - page.getHeaderMargin()) / 20;
            spm.getRegionBody().setMarginTop(required + "String_Node_Str");
          }
        }
      }
      if (spm.getRegionAfter() != null) {
        Integer fBpdaMilliPts=footerBpda.get(simplePageMasterName);
        if (fBpdaMilliPts == null) {
          log.error("String_Node_Str" + simplePageMasterName);
        }
 else {
          float fBpdaPts=fBpdaMilliPts / 1000;
          spm.getRegionAfter().setExtent(fBpdaPts + "String_Node_Str");
          spm.getRegionBody().setMarginBottom(fBpdaPts + "String_Node_Str");
          float totalHeight=(page.getFooterMargin() / 20) + fBpdaPts;
          float extraMargin=(page.getPgMar().getBottom().intValue() / 20) - totalHeight;
          if (extraMargin > 0) {
            float required=(page.getPgMar().getBottom().intValue() - page.getFooterMargin()) / 20;
            spm.getRegionBody().setMarginBottom(extraMargin + "String_Node_Str");
          }
        }
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * Inject the calculated heights for each header and footer, and adjust the region body margins to fit them.
 * @param layoutMasterSet
 * @param headerBpda
 * @param footerBpda
 */
static void adjustLayoutMasterSet(LayoutMasterSet layoutMasterSet,ConversionSectionWrappers conversionSectionWrappers,Map<String,Integer> headerBpda,Map<String,Integer> footerBpda){
  List<ConversionSectionWrapper> sections=conversionSectionWrappers.getList();
  ConversionSectionWrapper section=null;
  for (  Object o : layoutMasterSet.getSimplePageMasterOrPageSequenceMaster()) {
    if (o instanceof SimplePageMaster) {
      SimplePageMaster spm=((SimplePageMaster)o);
      String simplePageMasterName=spm.getMasterName();
      int index=-1 + Integer.parseInt(simplePageMasterName.substring(1,simplePageMasterName.indexOf("String_Node_Str")));
      PageDimensions page=null;
      if (sections.get(index) == null) {
        log.error("String_Node_Str" + index + "String_Node_Str"+ simplePageMasterName);
      }
 else {
        page=sections.get(index).getPageDimensions();
      }
      if (spm.getRegionBefore() != null) {
        Integer hBpdaMilliPts=headerBpda.get(simplePageMasterName);
        if (hBpdaMilliPts == null) {
          log.error("String_Node_Str" + simplePageMasterName);
        }
 else {
          float hBpdaPts=hBpdaMilliPts / 1000;
          spm.getRegionBefore().setExtent(hBpdaPts + "String_Node_Str");
          spm.getRegionBody().setMarginTop(hBpdaPts + "String_Node_Str");
          float totalHeight=(page.getHeaderMargin() / 20) + hBpdaPts;
          float extraMargin=(page.getPgMar().getTop().intValue() / 20) - totalHeight;
          if (extraMargin > 0) {
            float required=(page.getPgMar().getTop().intValue() - page.getHeaderMargin()) / 20;
            spm.getRegionBody().setMarginTop(required + "String_Node_Str");
          }
        }
      }
      if (spm.getRegionAfter() != null) {
        Integer fBpdaMilliPts=footerBpda.get(simplePageMasterName);
        if (fBpdaMilliPts == null) {
          log.error("String_Node_Str" + simplePageMasterName);
        }
 else {
          float fBpdaPts=fBpdaMilliPts / 1000;
          spm.getRegionAfter().setExtent(fBpdaPts + "String_Node_Str");
          spm.getRegionBody().setMarginBottom(fBpdaPts + "String_Node_Str");
          float totalHeight=(page.getFooterMargin() / 20) + fBpdaPts;
          float extraMargin=(page.getPgMar().getBottom().intValue() / 20) - totalHeight;
          if (extraMargin > 0) {
            float required=(page.getPgMar().getBottom().intValue() - page.getFooterMargin()) / 20;
            spm.getRegionBody().setMarginBottom(required + "String_Node_Str");
          }
        }
      }
    }
  }
}