Program: 45195
Project: 45195
Buggy source:
private Long persistRuleTerm(Long uKey,Long filtKey,RuleTerm r){
  if (_log.isDebugEnabled())   _log.debug("String_Node_Str" + r + "String_Node_Str"+ filtKey);
  Object op1=r.getOperand1();
  Object op2=r.getOperand2();
  Long op1Key=null;
  Long op2Key=null;
  Long rtKey=null;
switch (r.getType()) {
case LEAF_CONCEPT:
    op1Key=persistConcept(uKey,(Concept)op1);
  op2Key=new Long(((Filter.LeafConcept)r).getMinOccurences());
rtKey=(Long)INSERT_RULE_TERM.execute(new Object[]{filtKey,Filter.getValue(r.getType()),op1Key,op2Key});
break;
case LEAF_CAT:
op1Key=((Category)op1).getKey();
if (op1Key == null) {
_log.error("String_Node_Str" + op1);
_log.error("String_Node_Str" + op1Key.longValue());
}
rtKey=(Long)INSERT_RULE_TERM.execute(new Object[]{filtKey,Filter.getValue(r.getType()),op1Key,op2Key});
break;
case LEAF_FILTER:
op1Key=((Filter)op1).getKey();
if (op1Key < 0) {
_log.error("String_Node_Str" + op1);
op1Key=null;
_log.error("String_Node_Str" + op1Key.longValue());
}
rtKey=(Long)INSERT_RULE_TERM.execute(new Object[]{filtKey,Filter.getValue(r.getType()),op1Key,op2Key});
break;
case NOT_TERM:
op1Key=persistRuleTerm(uKey,filtKey,(RuleTerm)op1);
rtKey=(Long)INSERT_RULE_TERM.execute(new Object[]{filtKey,Filter.getValue(r.getType()),op1Key,op2Key});
break;
case AND_TERM:
case OR_TERM:
op1Key=persistRuleTerm(uKey,filtKey,(RuleTerm)op1);
op2Key=persistRuleTerm(uKey,filtKey,(RuleTerm)op2);
rtKey=(Long)INSERT_RULE_TERM.execute(new Object[]{filtKey,Filter.getValue(r.getType()),op1Key,op2Key});
break;
case CONTEXT_TERM:
op1Key=persistRuleTerm(uKey,filtKey,(RuleTerm)op1);
rtKey=(Long)INSERT_RULE_TERM.execute(new Object[]{filtKey,Filter.getValue(r.getType()),op1Key,op2Key});
List<Concept> cpts=(List<Concept>)op2;
for (Concept cpt : cpts) {
INSERT_RULE_TERM.execute(new Object[]{filtKey,CONTEXT_TERM_OPERAND_TYPE,rtKey,cpt.getKey()});
}
break;
case PROXIMITY_TERM:
op1Key=persistConcept(uKey,(Concept)op1);
op2Key=persistConcept(uKey,(Concept)op2);
rtKey=(Long)INSERT_RULE_TERM.execute(new Object[]{filtKey,Filter.getValue(r.getType()),op1Key,op2Key});
INSERT_RULE_TERM.execute(new Object[]{filtKey,PROXIMITY_TERM_OPERAND_TYPE,rtKey,(long)((ProximityTerm)r).getProximityVal()});
break;
}
return rtKey;
}

Fixed version (ground truth):
private Long persistRuleTerm(Long uKey,Long filtKey,RuleTerm r){
  if (_log.isDebugEnabled())   _log.debug("String_Node_Str" + r + "String_Node_Str"+ filtKey);
  Object op1=r.getOperand1();
  Object op2=r.getOperand2();
  Long op1Key=null;
  Long op2Key=null;
  Long rtKey=null;
switch (r.getType()) {
case LEAF_CONCEPT:
    op1Key=persistConcept(uKey,(Concept)op1);
  op2Key=new Long(((Filter.LeafConcept)r).getMinOccurences());
rtKey=(Long)INSERT_RULE_TERM.execute(new Object[]{filtKey,Filter.getValue(r.getType()),op1Key,op2Key});
break;
case LEAF_CAT:
op1Key=((Category)op1).getKey();
if (op1Key == null) {
_log.error("String_Node_Str" + op1);
_log.error("String_Node_Str" + op1Key.longValue());
}
rtKey=(Long)INSERT_RULE_TERM.execute(new Object[]{filtKey,Filter.getValue(r.getType()),op1Key,op2Key});
break;
case SOURCE_FILTER:
op1Key=((NR_Collection)op1).getKey();
rtKey=(Long)INSERT_RULE_TERM.execute(new Object[]{filtKey,Filter.getValue(r.getType()),op1Key,op2Key});
break;
case LEAF_FILTER:
op1Key=((Filter)op1).getKey();
if (op1Key < 0) {
_log.error("String_Node_Str" + op1);
op1Key=null;
_log.error("String_Node_Str" + op1Key.longValue());
}
rtKey=(Long)INSERT_RULE_TERM.execute(new Object[]{filtKey,Filter.getValue(r.getType()),op1Key,op2Key});
break;
case NOT_TERM:
op1Key=persistRuleTerm(uKey,filtKey,(RuleTerm)op1);
rtKey=(Long)INSERT_RULE_TERM.execute(new Object[]{filtKey,Filter.getValue(r.getType()),op1Key,op2Key});
break;
case AND_TERM:
case OR_TERM:
op1Key=persistRuleTerm(uKey,filtKey,(RuleTerm)op1);
op2Key=persistRuleTerm(uKey,filtKey,(RuleTerm)op2);
rtKey=(Long)INSERT_RULE_TERM.execute(new Object[]{filtKey,Filter.getValue(r.getType()),op1Key,op2Key});
break;
case CONTEXT_TERM:
op1Key=persistRuleTerm(uKey,filtKey,(RuleTerm)op1);
rtKey=(Long)INSERT_RULE_TERM.execute(new Object[]{filtKey,Filter.getValue(r.getType()),op1Key,op2Key});
List<Concept> cpts=(List<Concept>)op2;
for (Concept cpt : cpts) {
INSERT_RULE_TERM.execute(new Object[]{filtKey,CONTEXT_TERM_OPERAND_TYPE,rtKey,cpt.getKey()});
}
break;
case PROXIMITY_TERM:
op1Key=persistConcept(uKey,(Concept)op1);
op2Key=persistConcept(uKey,(Concept)op2);
rtKey=(Long)INSERT_RULE_TERM.execute(new Object[]{filtKey,Filter.getValue(r.getType()),op1Key,op2Key});
INSERT_RULE_TERM.execute(new Object[]{filtKey,PROXIMITY_TERM_OPERAND_TYPE,rtKey,(long)((ProximityTerm)r).getProximityVal()});
break;
default :
throw new Error("String_Node_Str" + r.getType() + "String_Node_Str"+ filtKey+ "String_Node_Str"+ uKey);
}
return rtKey;
}