Program: 146766
Project: 146766
Buggy source:
/** 
 * @param context A data model which is compatible with any xpath functions in the underlying Text
 * @return The evaluated string value for this Text object.
 */
public String evaluate(EvaluationContext context){
switch (type) {
case TEXT_TYPE_FLAT:
    return argument;
case TEXT_TYPE_LOCALE:
  String id=argument;
if (argument.equals("String_Node_Str")) {
  id=arguments.get("String_Node_Str").evaluate(context);
}
return Localization.get(id);
case TEXT_TYPE_XPATH:
try {
if (cacheParse == null) {
cacheParse=XPathParseTool.parseXPath("String_Node_Str" + argument + "String_Node_Str");
}
EvaluationContext temp=new EvaluationContext(context,context == null ? null : context.getContextRef());
temp.addFunctionHandler(new IFunctionHandler(){
public Object eval(Object[] args,EvaluationContext ec){
  Object o=XPathFuncExpr.toDate(args[0]);
  if (!(o instanceof Date)) {
    return "String_Node_Str";
  }
  String type=(String)args[1];
  int format=DateUtils.FORMAT_HUMAN_READABLE_SHORT;
  if (type.equals("String_Node_Str")) {
    format=DateUtils.FORMAT_HUMAN_READABLE_SHORT;
  }
 else   if (type.equals("String_Node_Str")) {
    format=DateUtils.FORMAT_ISO8601;
  }
  return DateUtils.formatDate((Date)o,format);
}
public String getName(){
  return "String_Node_Str";
}
public Vector getPrototypes(){
  Vector format=new Vector();
  Class[] prototypes=new Class[]{Date.class,String.class};
  format.addElement(prototypes);
  return format;
}
public boolean rawArgs(){
  return false;
}
public boolean realTime(){
  return false;
}
}
);
temp.addFunctionHandler(new IFunctionHandler(){
public Object eval(Object[] args,EvaluationContext ec){
  Calendar c=Calendar.getInstance();
  c.setTime(new Date());
  return String.valueOf(c.get(Calendar.DAY_OF_WEEK));
}
public String getName(){
  return "String_Node_Str";
}
public Vector getPrototypes(){
  Vector format=new Vector();
  Class[] prototypes=new Class[]{};
  format.addElement(prototypes);
  return format;
}
public boolean rawArgs(){
  return false;
}
public boolean realTime(){
  return false;
}
}
);
for (Enumeration en=arguments.keys(); en.hasMoreElements(); ) {
String key=(String)en.nextElement();
String value=arguments.get(key).evaluate(context);
temp.setVariable(key,value);
}
return (String)cacheParse.eval(context.getMainInstance(),context);
}
 catch (XPathSyntaxException e) {
e.printStackTrace();
}
return argument;
case TEXT_TYPE_COMPOSITE:
String ret="String_Node_Str";
for (int i=0; i < arguments.size(); ++i) {
Text item=arguments.get(String.valueOf(i));
ret+=item.evaluate(context) + "String_Node_Str";
}
return ret;
default :
return argument;
}
}

Fixed version (ground truth):
/** 
 * @param context A data model which is compatible with any xpath functions in the underlying Text
 * @return The evaluated string value for this Text object.
 */
public String evaluate(EvaluationContext context){
switch (type) {
case TEXT_TYPE_FLAT:
    return argument;
case TEXT_TYPE_LOCALE:
  String id=argument;
if (argument.equals("String_Node_Str")) {
  id=arguments.get("String_Node_Str").evaluate(context);
}
return Localization.get(id);
case TEXT_TYPE_XPATH:
try {
if (cacheParse == null) {
cacheParse=XPathParseTool.parseXPath("String_Node_Str" + argument + "String_Node_Str");
}
EvaluationContext temp;
if (context == null) {
temp=new EvaluationContext(null);
}
 else {
temp=new EvaluationContext(context,context.getContextRef());
}
temp.addFunctionHandler(new IFunctionHandler(){
public Object eval(Object[] args,EvaluationContext ec){
  Object o=XPathFuncExpr.toDate(args[0]);
  if (!(o instanceof Date)) {
    return "String_Node_Str";
  }
  String type=(String)args[1];
  int format=DateUtils.FORMAT_HUMAN_READABLE_SHORT;
  if (type.equals("String_Node_Str")) {
    format=DateUtils.FORMAT_HUMAN_READABLE_SHORT;
  }
 else   if (type.equals("String_Node_Str")) {
    format=DateUtils.FORMAT_ISO8601;
  }
  return DateUtils.formatDate((Date)o,format);
}
public String getName(){
  return "String_Node_Str";
}
public Vector getPrototypes(){
  Vector format=new Vector();
  Class[] prototypes=new Class[]{Date.class,String.class};
  format.addElement(prototypes);
  return format;
}
public boolean rawArgs(){
  return false;
}
public boolean realTime(){
  return false;
}
}
);
temp.addFunctionHandler(new IFunctionHandler(){
public Object eval(Object[] args,EvaluationContext ec){
  Calendar c=Calendar.getInstance();
  c.setTime(new Date());
  return String.valueOf(c.get(Calendar.DAY_OF_WEEK));
}
public String getName(){
  return "String_Node_Str";
}
public Vector getPrototypes(){
  Vector format=new Vector();
  Class[] prototypes=new Class[]{};
  format.addElement(prototypes);
  return format;
}
public boolean rawArgs(){
  return false;
}
public boolean realTime(){
  return false;
}
}
);
for (Enumeration en=arguments.keys(); en.hasMoreElements(); ) {
String key=(String)en.nextElement();
String value=arguments.get(key).evaluate(context);
temp.setVariable(key,value);
}
return (String)cacheParse.eval(temp.getMainInstance(),temp);
}
 catch (XPathSyntaxException e) {
e.printStackTrace();
}
return argument;
case TEXT_TYPE_COMPOSITE:
String ret="String_Node_Str";
for (int i=0; i < arguments.size(); ++i) {
Text item=arguments.get(String.valueOf(i));
ret+=item.evaluate(context) + "String_Node_Str";
}
return ret;
default :
return argument;
}
}