Uploaded image for project: 'Drools'
  1. Drools
  2. DROOLS-1015

Wrong MvelConstraint compilation with Unicode class name and the same name property

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Won't Do
    • Icon: Major Major
    • 7.0.0.Final
    • 6.3.0.Final
    • core engine
    • None
    • Workaround Exists
    • Hide
      • A. Add "this." to the property. for example, ( 住所 != null ) -> ( this.住所 != null )
        or
      • B. Use a different property name from class name
      Show
      A. Add "this." to the property. for example, ( 住所 != null ) -> ( this.住所 != null ) or B. Use a different property name from class name
    • NEW
    • NEW

      If a fact has a property of Unicode class name (e.g. 住所) and the property name is the same (住所), constraint is not correctly compiled by MVEL. Internally, AbstractParser.createPropertyToken() misunderstands the property as a class name literal.

      public class I18nPerson implements Serializable {
          private 住所 住所; // "address" in Japanese
          public 住所 get住所() {
              return 住所;
          }
          ....
      
      when
        p : I18nPerson( 住所 != null )
      

      This constraint is always evaluated to "true".

      Essentially, this is not only a problem of Unicode. We can reproduce the issue by a capitalized property name.

      public class Person implements Serializable {
          private Address address;
          public Address getAddress() {
              return address;
          }
          ....
      
      when
        p : I18nPerson( Address != null )
      

      Of course we should use lower case letters here from JavaBeans point of view so we don't hit this issue with English usually. But some languages like Japanese cannot express "lower case/upper case" so result in this issue.

            mfusco@redhat.com Mario Fusco
            rhn-support-tkobayas Toshiya Kobayashi
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: