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

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

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major Major
    • 7.0.0.Beta3
    • None
    • core engine
    • None
    • NEW
    • NEW

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

              mmortari@redhat.com Matteo Mortari
              mfusco@redhat.com Mario Fusco
              Votes:
              1 Vote for this issue
              Watchers:
              3 Start watching this issue

                Created:
                Updated:
                Resolved: