[jboss-svn-commits] JBL Code SVN: r18332 - labs/jbossrules/branches/4.0.x/drools-core/src/main/java/org/drools/base/evaluators.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Tue Feb 5 19:10:17 EST 2008
Author: tirelli
Date: 2008-02-05 19:10:17 -0500 (Tue, 05 Feb 2008)
New Revision: 18332
Modified:
labs/jbossrules/branches/4.0.x/drools-core/src/main/java/org/drools/base/evaluators/ObjectFactory.java
Log:
JBRULES-1435: adding checks for nulls
Modified: labs/jbossrules/branches/4.0.x/drools-core/src/main/java/org/drools/base/evaluators/ObjectFactory.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-core/src/main/java/org/drools/base/evaluators/ObjectFactory.java 2008-02-06 00:01:32 UTC (rev 18331)
+++ labs/jbossrules/branches/4.0.x/drools-core/src/main/java/org/drools/base/evaluators/ObjectFactory.java 2008-02-06 00:10:17 UTC (rev 18332)
@@ -544,8 +544,8 @@
// trying to implement runtime type coercion
public boolean equals( Object arg0, Object arg1 ) {
- if ( arg0 == null ) {
- return arg1 == null;
+ if ( arg0 == null || arg1 == null ) {
+ return arg0 == arg1;
}
if( arg1 != null && arg1 instanceof ShadowProxy ) {
return arg1.equals( arg0 );
@@ -558,7 +558,7 @@
} else if( arg1 instanceof String ) {
val1 = Double.parseDouble( ( String ) arg1 );
} else {
- throw new ClassCastException( "Not possible to convert "+arg1.getClass()+" into a double value to compare it to "+arg0.getClass() );
+ throw new ClassCastException( "Not possible to compare "+arg1.getClass()+" to "+arg0.getClass() );
}
return val0 == val1; // in the future we may need to handle rounding errors
}
@@ -586,6 +586,13 @@
public int compare(Object arg0,
Object arg1) {
+ if( arg0 == null || arg1 == null ) {
+ if( arg0 == arg1 ) {
+ return 0;
+ } else {
+ throw new NullPointerException( "Can't compare "+arg0+" to "+arg1 );
+ }
+ }
if( arg0 instanceof Double || arg0 instanceof Float ) {
double val0 = ((Number) arg0).doubleValue();
double val1 = 0;
More information about the jboss-svn-commits
mailing list