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

Error to declare Map/List with generics when having a modify() on RHS

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major Major
    • 6.2.0.CR1
    • None
    • None
    • None

      For the following rule

      -----------------------------
      package com.sample

      import java.util.Map;
      import java.util.HashMap;

      declare TestFact
      @propertyReactive
      data : String
      end

      rule "Test Rule"
      when
      $fact : TestFact()
      then
      Map<String,String> a = new HashMap<String,String>();
      modify ($fact)

      {setData("0")}

      end
      ------------------------

      We get the following exception:

      java.lang.RuntimeException: Error while creating KieBase[Message [id=1, level=ERROR, path=rules/Sample.drl, line=11, column=0
      text=Unable to resolve type Map<String,String>:
      Unable to find class 'Map<String,String>']]
      at org.drools.compiler.kie.builder.impl.KieContainerImpl.getKieBase(KieContainerImpl.java:260)
      at org.drools.compiler.kie.builder.impl.KieContainerImpl.newKieSession(KieContainerImpl.java:400)
      at org.drools.compiler.kie.builder.impl.KieContainerImpl.newKieSession(KieContainerImpl.java:375)
      at com.sample.DroolsTest.main(DroolsTest.java:17)

      If we remove the generics, or not using modify(), this has no error.

              mfusco@redhat.com Mario Fusco
              jinghai.rao Jinghai Rao (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

                Created:
                Updated:
                Resolved: