3 Replies Latest reply on Jun 20, 2008 2:28 PM by Ronald van Kuijk

    Is this a bug or is it intentional

    Shai Bentin Newbie

      I'm running jbpm 3.1.1 on my site for a long time. Today I tried to see what I need to do in order to upgrade to 3.2.3. Aside from migrating the DB, I found several things. One of the things is something I submitted a jira issue jbpm-696 (which was accepted as a fix and closed).

      In FieldInstantiator line 140 - 141:

      else if (Map.class.isAssignableFrom(type)) {
       value = getMap(propertyElement, new HashMap());


      This makes the developer of an actionHandler use only the HashMap type as his map type, otherwise if you use hashtable you won't be able to set it. What I suggested back on that fix (applies also to collection types) is to write the code like this:

      else if (Map.class.isAssignableFrom(type)) {
       value = getMap(propertyElement, (Map)type.newInstance());


      this allows the developer to use any kind of map type even his own implementation.

      My question is: Is it intentional not to allow other map or collection types or is it just an oversight?

        • 1. Re: Is this a bug or is it intentional
          Alejandro Guizar Master

          I see problems with both the current code and your proposed fix.

          The current code fails for the declaration below, because it will try to assign a HashMap to a Hashtable.

          Hashtable keyCodes;


          The proposed fix actually makes things worse because the following declaration is the common case. Class.newInstance() fails for interfaces.
          Map keyCodes;


          The definitive solution should address both scenarios. I'll reopen the issue and add this comment.

          • 2. Re: Is this a bug or is it intentional
            Shai Bentin Newbie

            I agree both scanarios should be addressed. Addressing the interface issue is not hard as we can do

            type.isInterface()



            However this leaves two problems. Both are not common. use cases.
            1. Abstract classes which if someone uses it is imposible to get it to work, since it will fail on 'Field.set'.

            2. Another problem is when a user uses his own sub interface.

            I think the code should address the first two issues and state in the documentation not to use abstract classes or sub interfaces of Collection, Set, List and Map for field mapping. (Maybe add an clear exception message)

            • 3. Re: Is this a bug or is it intentional
              Ronald van Kuijk Master

              look in the jira, I think Alex already has a solution there