[
http://jira.jboss.com/jira/browse/JBRULES-1451?page=comments#action_12398681 ]
Edson Tirelli commented on JBRULES-1451:
----------------------------------------
There was indeed a type coercion bug in a very specific case.
Although, it is important to note that by Java's API definition, any string different
from "true" (ignore case) will be coerced to Boolean.FALSE when converting to
boolean:
http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Boolean.html#valueOf(ja...
So, the expression bellow (although may not be intuitive) returns true:
Boolean.FALSE == "foo"
Thanks for reporting.
LHS expression comparing a Boolean to a String does not fail but
always returns true
------------------------------------------------------------------------------------
Key: JBRULES-1451
URL:
http://jira.jboss.com/jira/browse/JBRULES-1451
Project: JBoss Drools
Issue Type: Bug
Security Level: Public(Everyone can see)
Affects Versions: 4.0.3, 4.0.4
Environment: Eclipse IDE Version: 3.3.0 Build id: M20070921-1145
Windows XP Professional SP2
Reporter: Len Carlsen
Assigned To: Edson Tirelli
LHS expression comparing a Boolean to a String does not fail but always returns true.
Example:
--------------------------------------------------------------------------------------------------------------------------
Modified the Drools HelloWorldExample and changed the status from an int to a boolean.
import org.drools.examples.HelloWorldExample.Message;
rule "Hello World"
when
m : Message( status == "hello", message : message )
then
System.out.println( message );
end
public static class Message {
public static final boolean HELLO = false;
public static final boolean GOODBYE = true;
private String message;
private Boolean status;
public Message() {}
public String getMessage() { return this.message; }
public void setMessage(final String message) { this.message = message; }
public boolean getStatus() { return this.status; }
public void setStatus(final boolean status) { this.status = status; }
}
final Message message = new Message();
message.setMessage( "Hello World" );
message.setStatus( Message.HELLO );
final StatefulSession session = ruleBase.newStatefulSession();
session.insert( message );
session.fireAllRules();
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://jira.jboss.com/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira