Program: 21586
Project: 21586
Buggy source:
public void run(){
  if (outputFile == null) {
    return;
  }
  if (topLevelOTObjects[0] != null) {
    controllerService=topLevelOTObjects[0].getOTObjectService().createControllerService();
    OTControllerServiceFactory controllerServiceFactory=new OTControllerServiceFactory(){
      public OTControllerService createControllerService(      OTObjectService objectService){
        OTControllerService subControllerService=((OTControllerServiceImpl)controllerService).createSubControllerService(objectService);
        return subControllerService;
      }
      /** 
 * @deprecated the object service should be passed in otherwise applications whichuse multiple overlay databases will not function properly
 * @see org.concord.framework.otrunk.view.OTControllerServiceFactory#createControllerService()
 */
      public OTControllerService createControllerService(){
        OTObjectService objectService=((OTControllerServiceImpl)controllerService).getObjectService();
        return createControllerService(objectService);
      }
    }
;
    OTViewContext factoryContext=viewFactory.getViewContext();
    factoryContext.addViewService(OTControllerServiceFactory.class,controllerServiceFactory);
  }
  String allTexts="String_Node_Str";
  for (int i=0; i < topLevelOTObjects.length; i++) {
    if (topLevelOTObjects[i] == null) {
      continue;
    }
    String text=null;
    OTJComponentView objView=getOTJComponentView(topLevelOTObjects[i],null,topLevelViewEntries[i]);
    OTXHTMLView xhtmlView=null;
    String bodyText="String_Node_Str";
    if (objView instanceof OTXHTMLView) {
      xhtmlView=(OTXHTMLView)objView;
      bodyText=xhtmlView.getXHTMLText(topLevelOTObjects[i]);
      Pattern p=Pattern.compile("String_Node_Str");
      Matcher m=p.matcher(bodyText);
      StringBuffer parsed=new StringBuffer();
      OTObjectService objectService=topLevelOTObjects[i].getOTObjectService();
      while (m.find()) {
        String id=m.group(1);
        OTID otid=objectService.getOTID(id);
        OTObject referencedObject=null;
        try {
          referencedObject=objectService.getOTObject(otid);
        }
 catch (        Exception e1) {
          e1.printStackTrace();
        }
        Pattern userPat=Pattern.compile("String_Node_Str");
        Matcher userMatcher=userPat.matcher(m.group(2));
        if (userMatcher.find()) {
          String userId=userMatcher.group(1);
          referencedObject=getRuntimeObject(referencedObject,userId);
        }
        OTViewEntry viewEntry=null;
        Pattern viewPat=Pattern.compile("String_Node_Str");
        Matcher viewMatcher=viewPat.matcher(m.group(2));
        if (viewMatcher.find()) {
          String viewId=viewMatcher.group(1);
          if (viewId != null && viewId.length() > 0) {
            OTID viewOTid=objectService.getOTID(viewId);
            try {
              viewEntry=(OTViewEntry)objectService.getOTObject(viewOTid);
            }
 catch (            Exception e) {
              e.printStackTrace();
            }
          }
        }
        String url=Matcher.quoteReplacement(embedOTObject(referencedObject,viewEntry));
        if (url != null) {
          try {
            m.appendReplacement(parsed,url);
          }
 catch (          IllegalArgumentException e) {
            System.err.println("String_Node_Str" + url);
            e.printStackTrace();
          }
catch (          IndexOutOfBoundsException e) {
            System.err.println("String_Node_Str" + url);
            e.printStackTrace();
          }
        }
      }
      m.appendTail(parsed);
      text="String_Node_Str" + parsed.toString() + "String_Node_Str";
    }
 else {
      text=embedOTObject(topLevelOTObjects[i],topLevelViewEntries[i]);
    }
    allTexts=allTexts + text;
  }
  try {
    FileWriter fos=new FileWriter(outputFile);
    fos.write("String_Node_Str" + allTexts + "String_Node_Str");
    fos.close();
  }
 catch (  FileNotFoundException exp) {
    exp.printStackTrace();
  }
catch (  IOException exp) {
    exp.printStackTrace();
  }
}

Fixed version (ground truth):
public void run(){
  boolean xhtmlOutput=OTConfig.getBooleanProp(XHTML_EXPORT_WRAP_PROP,true);
  if (outputFile == null) {
    return;
  }
  if (topLevelOTObjects[0] != null) {
    controllerService=topLevelOTObjects[0].getOTObjectService().createControllerService();
    OTControllerServiceFactory controllerServiceFactory=new OTControllerServiceFactory(){
      public OTControllerService createControllerService(      OTObjectService objectService){
        OTControllerService subControllerService=((OTControllerServiceImpl)controllerService).createSubControllerService(objectService);
        return subControllerService;
      }
      /** 
 * @deprecated the object service should be passed in otherwise applications whichuse multiple overlay databases will not function properly
 * @see org.concord.framework.otrunk.view.OTControllerServiceFactory#createControllerService()
 */
      public OTControllerService createControllerService(){
        OTObjectService objectService=((OTControllerServiceImpl)controllerService).getObjectService();
        return createControllerService(objectService);
      }
    }
;
    OTViewContext factoryContext=viewFactory.getViewContext();
    factoryContext.addViewService(OTControllerServiceFactory.class,controllerServiceFactory);
  }
  String allTexts="String_Node_Str";
  for (int i=0; i < topLevelOTObjects.length; i++) {
    if (topLevelOTObjects[i] == null) {
      continue;
    }
    String text=null;
    OTJComponentView objView=getOTJComponentView(topLevelOTObjects[i],null,topLevelViewEntries[i]);
    OTXHTMLView xhtmlView=null;
    String bodyText="String_Node_Str";
    if (objView instanceof OTXHTMLView) {
      xhtmlView=(OTXHTMLView)objView;
      bodyText=xhtmlView.getXHTMLText(topLevelOTObjects[i]);
      Pattern p=Pattern.compile("String_Node_Str");
      Matcher m=p.matcher(bodyText);
      StringBuffer parsed=new StringBuffer();
      OTObjectService objectService=topLevelOTObjects[i].getOTObjectService();
      while (m.find()) {
        String id=m.group(1);
        OTID otid=objectService.getOTID(id);
        OTObject referencedObject=null;
        try {
          referencedObject=objectService.getOTObject(otid);
        }
 catch (        Exception e1) {
          e1.printStackTrace();
        }
        Pattern userPat=Pattern.compile("String_Node_Str");
        Matcher userMatcher=userPat.matcher(m.group(2));
        if (userMatcher.find()) {
          String userId=userMatcher.group(1);
          referencedObject=getRuntimeObject(referencedObject,userId);
        }
        OTViewEntry viewEntry=null;
        Pattern viewPat=Pattern.compile("String_Node_Str");
        Matcher viewMatcher=viewPat.matcher(m.group(2));
        if (viewMatcher.find()) {
          String viewId=viewMatcher.group(1);
          if (viewId != null && viewId.length() > 0) {
            OTID viewOTid=objectService.getOTID(viewId);
            try {
              viewEntry=(OTViewEntry)objectService.getOTObject(viewOTid);
            }
 catch (            Exception e) {
              e.printStackTrace();
            }
          }
        }
        String url=Matcher.quoteReplacement(embedOTObject(referencedObject,viewEntry));
        if (url != null) {
          try {
            m.appendReplacement(parsed,url);
          }
 catch (          IllegalArgumentException e) {
            System.err.println("String_Node_Str" + url);
            e.printStackTrace();
          }
catch (          IndexOutOfBoundsException e) {
            System.err.println("String_Node_Str" + url);
            e.printStackTrace();
          }
        }
      }
      m.appendTail(parsed);
      if (xhtmlOutput) {
        text="String_Node_Str" + parsed.toString() + "String_Node_Str";
      }
 else {
        text=parsed.toString();
      }
    }
 else {
      text=embedOTObject(topLevelOTObjects[i],topLevelViewEntries[i]);
    }
    allTexts=allTexts + text;
  }
  try {
    FileWriter fos=new FileWriter(outputFile);
    if (xhtmlOutput) {
      fos.write("String_Node_Str" + allTexts + "String_Node_Str");
    }
 else {
      fos.write(allTexts);
    }
    fos.close();
  }
 catch (  FileNotFoundException exp) {
    exp.printStackTrace();
  }
catch (  IOException exp) {
    exp.printStackTrace();
  }
}