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

Duplicate rules name errors not being identified across multiple resources in same package

This issue belongs to an archived project. You can view it, but you can't modify it. Learn more

    XMLWordPrintable

Details

    • Hide

      To reproduce you need two DRL resource files

      DuplicateRuleName2.drl contains the following rule:
      package com.ccr.test

      rule "new rule"
      when
      BodyMassIndex(value <= 26)
      then
      System.out.println("BMI is less then or equal to 26");
      end

      DuplicateRuleName2.drl contains the following rule:
      package com.ccr.test

      rule "new rule"
      when
      BodyMassIndex(value <= 26)
      then
      System.out.println("BMI is less then or equal to 26");
      end

      Then add both resources to knowledge builder
      kbuilder.add(duplicateRuleName1, ResourceType.DRL);
      kbuilder.add(duplicateRuleName2, ResourceType.DRL);

      Show
      To reproduce you need two DRL resource files DuplicateRuleName2.drl contains the following rule: package com.ccr.test rule "new rule" when BodyMassIndex(value <= 26) then System.out.println("BMI is less then or equal to 26"); end DuplicateRuleName2.drl contains the following rule: package com.ccr.test rule "new rule" when BodyMassIndex(value <= 26) then System.out.println("BMI is less then or equal to 26"); end Then add both resources to knowledge builder kbuilder.add(duplicateRuleName1, ResourceType.DRL); kbuilder.add(duplicateRuleName2, ResourceType.DRL);

    Description

      The validateUniqueRuleNamesmethod in the org.drools.compiler.PackageBuilder class currently only checks for duplicate rule names that are defined within the same resource. However, in the case where there are multiple resources added to the knowledge builder that share the same package name then the validateUniqueRuleNames method is not detecting duplicates across the package.

      In cases where rules have the same name and are defined in the same package then I would have expected to get a duplicate rule error but I do not as the rules are physically reside in two separate resources.

      It seems logical that in addition to checking if any rules are duplicated within the resource that it also checks to see that rule was already defined in the package registry as well. Otherwise the last rule overwrites the first and creates some rather odd behavior.

      Attachments

        Issue Links

          Activity

            People

              mproctor@redhat.com Mark Proctor
              mpellegrini_jira Michael Pellegrini (Inactive)
              Archiver:
              rhn-support-ceverson Clark Everson

              Dates

                Created:
                Updated:
                Resolved:
                Archived:

                PagerDuty