Uploaded image for project: 'JBRULES'
  1. JBRULES
  2. JBRULES-1451

LHS expression comparing a Boolean to a String does not fail but always returns true

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Major
    • Resolution: Done
    • Affects Version/s: 4.0.3, 4.0.4
    • Fix Version/s: 4.0.5, 5.0.0.M1
    • Component/s: None
    • Labels:
      None
    • Environment:

      Eclipse IDE Version: 3.3.0 Build id: M20070921-1145
      Windows XP Professional SP2

      Description

      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();

        Gliffy Diagrams

          Attachments

            Activity

              People

              • Assignee:
                tirelli Edson Tirelli
                Reporter:
                lcarlsen Len Carlsen
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: