Program: 86789
Project: 86789
Buggy source:
/** 
 * @return a formatted version of the object suitable for display
 */
@SuppressWarnings({"String_Node_Str","String_Node_Str"}) public static String format(Object o,String format){
  if (o == null) {
    return "String_Node_Str";
  }
  if (o instanceof Date) {
    DateFormat df=decode(format,Context.getDateFormat(),new SimpleDateFormat(format));
    return df.format((Date)o);
  }
  if (o instanceof Map) {
    return toString((Map)o,nvl(format,"String_Node_Str"));
  }
  if (o instanceof Collection) {
    return OpenmrsUtil.join((Collection)o,nvl(format,"String_Node_Str"));
  }
  if (o instanceof Object[]) {
    return toString(nvl(format,"String_Node_Str"),(Object[])o);
  }
  if (o instanceof Number) {
    if (notNull(format)) {
      NumberFormat nf=NumberFormat.getInstance();
      nf.setGroupingUsed(false);
      return nf.format((Number)o);
    }
  }
  if (o instanceof OpenmrsMetadata) {
    String name=((OpenmrsMetadata)o).getName();
    if (name == null) {
      if (o instanceof ProgramWorkflow) {
        name=((ProgramWorkflow)o).getConcept().getDisplayString();
      }
 else       if (o instanceof ProgramWorkflowState) {
        name=((ProgramWorkflowState)o).getConcept().getDisplayString();
      }
    }
    return name;
  }
  if (o instanceof OpenmrsData) {
    if (ObjectUtil.notNull(format)) {
      String[] formatSplit=format.split("String_Node_Str");
      String ret=formatSplit[0];
      try {
        int startIndex=ret.indexOf("String_Node_Str");
        int endIndex=ret.indexOf("String_Node_Str",startIndex + 1);
        while (startIndex != -1 && endIndex != -1) {
          String propertyName=format.substring(startIndex + 1,endIndex);
          Object replacement=ReflectionUtil.getPropertyValue(o,propertyName);
          String newFormat=(replacement != null && formatSplit.length > 1 ? formatSplit[1] : null);
          replacement=ObjectUtil.format(replacement,newFormat);
          ret=ret.replace("String_Node_Str" + propertyName + "String_Node_Str",nvlStr(replacement,"String_Node_Str"));
          startIndex=ret.indexOf("String_Node_Str");
          endIndex=ret.indexOf("String_Node_Str",startIndex + 1);
        }
        return ret;
      }
 catch (      Exception e) {
        log.warn("String_Node_Str" + format,e);
      }
    }
  }
  return o.toString();
}

Fixed version (ground truth):
/** 
 * @return a formatted version of the object suitable for display
 */
@SuppressWarnings({"String_Node_Str","String_Node_Str"}) public static String format(Object o,String format){
  if (o == null) {
    return "String_Node_Str";
  }
  if (o instanceof Date) {
    DateFormat df=decode(format,Context.getDateFormat(),new SimpleDateFormat(format));
    return df.format((Date)o);
  }
  if (o instanceof Map) {
    return toString((Map)o,nvl(format,"String_Node_Str"));
  }
  if (o instanceof Collection) {
    return OpenmrsUtil.join((Collection)o,nvl(format,"String_Node_Str"));
  }
  if (o instanceof Object[]) {
    return toString(nvl(format,"String_Node_Str"),(Object[])o);
  }
  if (o instanceof Number) {
    if (notNull(format)) {
      NumberFormat nf=NumberFormat.getInstance();
      nf.setGroupingUsed(false);
      return nf.format((Number)o);
    }
  }
  if (o instanceof OpenmrsMetadata) {
    String name=((OpenmrsMetadata)o).getName();
    if (name == null) {
      if (o instanceof ProgramWorkflow) {
        name=((ProgramWorkflow)o).getConcept().getDisplayString();
      }
 else       if (o instanceof ProgramWorkflowState) {
        name=((ProgramWorkflowState)o).getConcept().getDisplayString();
      }
    }
    return name;
  }
  if (o instanceof OpenmrsData) {
    if (ObjectUtil.notNull(format)) {
      String[] formatSplit=format.split("String_Node_Str");
      String ret=formatSplit[0];
      try {
        int startIndex=ret.indexOf("String_Node_Str");
        int endIndex=ret.indexOf("String_Node_Str",startIndex + 1);
        while (startIndex != -1 && endIndex != -1) {
          String propertyName=ret.substring(startIndex + 1,endIndex);
          Object replacement=ReflectionUtil.getPropertyValue(o,propertyName);
          String newFormat=(replacement != null && formatSplit.length > 1 ? formatSplit[1] : null);
          replacement=ObjectUtil.format(replacement,newFormat);
          ret=ret.replace("String_Node_Str" + propertyName + "String_Node_Str",nvlStr(replacement,"String_Node_Str"));
          startIndex=ret.indexOf("String_Node_Str");
          endIndex=ret.indexOf("String_Node_Str",startIndex + 1);
        }
        return ret;
      }
 catch (      Exception e) {
        log.warn("String_Node_Str" + format,e);
      }
    }
  }
  return o.toString();
}