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

A FQN inline cast followed by a method invocation causes an ArrayIndexOutOfBoundsException

    Details

    • Docs QE Status:
      NEW
    • QE Status:
      NEW

      Description

      An inline cast using a fully qualified name followed by a method invocation causes an ArrayIndexOutOfBoundsException as in the following test case:

          @Test
          public void testInlineCastWithFQNAndMethodInvocation() throws Exception {
              String str =
                      "import org.drools.compiler.Person;\n" +
                      "global java.util.List list;\n" +
                      "rule R1 when\n" +
                      "   Person( name == \"mark\", $x : address#org.drools.compiler.LongAddress.country.substring(1) )\n" +
                      "then\n" +
                      "   list.add($x);" +
                      "end\n";
      
              KnowledgeBase kbase = loadKnowledgeBaseFromString(str);
              StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();
      
              List<String> list = new ArrayList<String>();
              ksession.setGlobal( "list", list );
      
              Person mark1 = new Person("mark");
              mark1.setAddress(new LongAddress("uk"));
              ksession.insert(mark1);
      
              assertEquals(1, ksession.fireAllRules());
              assertEquals(1, list.size());
              assertEquals("k", list.get(0));
      
              ksession.dispose();
          }
      

        Gliffy Diagrams

          Attachments

            Activity

              People

              • Assignee:
                tari_manga Matteo Mortari
                Reporter:
                mfusco Mario Fusco
              • Votes:
                1 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: