-
Bug
-
Resolution: Done
-
Major
-
6.0.0.Beta3
-
None
-
None
If you compare String fields which consist of many digits, it may be wrongly evaluated due to String to Double coercion and Double's inaccuracy.
The following test doesn't fire the rule.
import org.drools.compiler.Person; rule R1 when $p : Person( name < "90201304122000000000000017" ) then end
ksession.insert( new Person( "90201304122000000000000015", 38 ) );
In Drools 6.0.0.beta3, the coercion is done by org.mvel2.math.MathProcessor
public strictfp class MathProcessor { ... private static Object _doOperations(int type1, Object val1, int operation, int type2, Object val2) { if (operation < 20) { if (((type1 > 49 || operation == EQUAL || operation == NEQUAL) && type1 == type2) || (isIntegerType(type1) && isIntegerType(type2) && operation >= BW_AND && operation <= BW_NOT)) { return doOperationsSameType(type1, val1, operation, val2); } else if ((type1 > 99 && (type2 > 99)) || (operation != 0 && isNumber(val1) && isNumber(val2))) { return doPrimWrapperArithmetic(getNumber(val1, type1), operation, getNumber(val2, type2), true, box(type2) > box(type1) ? box(type2) : box(type1)); } ... private static Double getNumber(Object in, int type) { if (in == null) return 0d; switch (type) { ... case DataTypes.STRING: return Double.parseDouble((String) in); ...
- is incorporated by
-
DROOLS-68 Rules evaluation fails after several iterations, when number comparsion is done with quote surrounded values
- Resolved