Uploaded image for project: 'jBPM'
  1. jBPM
  2. JBPM-3171

Setting key on process instance causes instance variables to be mis-placed

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major Major
    • jBPM 3.2.11
    • jBPM 3.2.10
    • Runtime Engine
    • None
    • Workaround Exists
    • Hide

      Don't set the key after instance construction. (Not usable for some legacy customers upgrading.)

      Show
      Don't set the key after instance construction. (Not usable for some legacy customers upgrading.)
    • Hide

      Based off example jBPM included in JBDS, run this as a JUnit:

      **********************************************************************************************************************

      HashMap<String,Object> params = new HashMap<String, Object>();
      params.put("AString", new String("AString_value"));
      params.put("AnotherString", new String("AnotherString_value"));

      // Extract a process definition from the processdefinition.xml file.
      ProcessDefinition processDefinition = ProcessDefinition.parseXmlResource("simple/processdefinition.xml");

      // Create an instance of the process definition.
      ProcessInstance instance = new ProcessInstance(processDefinition, params);
      instance.getContextInstance().setVariable("userId", new String("userId_Value"));

      String var1 = (String)instance.getContextInstance().getVariables().get("userId");
      assertEquals("Process Variable didn't match as expected",
      "userId_Value", var1);

      instance.setKey("MyKey"); // Uh-oh! This causes trouble

      String var2 = (String)instance.getContextInstance().getVariables().get("userId"); // same test that passed a moment ago...
      assertEquals("Process Variable didn't match as expected",
      "userId_Value", var2);

      **************************************************************************************************************************

      Show
      Based off example jBPM included in JBDS, run this as a JUnit: ********************************************************************************************************************** HashMap<String,Object> params = new HashMap<String, Object>(); params.put("AString", new String("AString_value")); params.put("AnotherString", new String("AnotherString_value")); // Extract a process definition from the processdefinition.xml file. ProcessDefinition processDefinition = ProcessDefinition.parseXmlResource("simple/processdefinition.xml"); // Create an instance of the process definition. ProcessInstance instance = new ProcessInstance(processDefinition, params); instance.getContextInstance().setVariable("userId", new String("userId_Value")); String var1 = (String)instance.getContextInstance().getVariables().get("userId"); assertEquals("Process Variable didn't match as expected", "userId_Value", var1); instance.setKey("MyKey"); // Uh-oh! This causes trouble String var2 = (String)instance.getContextInstance().getVariables().get("userId"); // same test that passed a moment ago... assertEquals("Process Variable didn't match as expected", "userId_Value", var2); **************************************************************************************************************************

      Setting the key on a process instance causes variables to be mis-handled. See JUnit example in 'steps to reproduce' below.

              rhn-support-mputz Martin Weiler (Inactive)
              rhn-support-mputz Martin Weiler (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved: