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

collectList on objects of type java.lang.Class get returned as null

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major Major
    • 6.2.0.CR1
    • 6.2.0.Beta1
    • None
    • Snapshot Drools 6.2.0.201410031437 runtime

      If collectList in an accumulate is supplied objects of type java.lang.Class, then subsequent examination of the supplied list yields null values rather than the expect Class values.

      Test case below. Swapping the comments to make InitClass have a String field instead of a Class field changes the behaviour of the list from collectList to what one would expect.

      package com.sample

      declare MyClass end

      declare InitClass
      clazz: Class @key
      // clazz: String @key
      end

      rule "init"
      when
      then
      insert( new InitClass( MyClass.class ) );
      // insert( new InitClass( "some string" ) );
      end

      rule "make init classes"
      when
      accumulate( InitClass( $clazz; ), $list: collectList( $clazz ) )
      then
      System.out.printf("%d items in list\n", $list.size());
      for(Object obj : $list)
      System.out.printf("item is %s\n", obj);
      end

      rule "show init classes"
      when
      InitClass( $v; )
      then
      System.out.printf("match %s\n", $v);
      end

              mfusco@redhat.com Mario Fusco
              borris_jira David Fell (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved: