Bug 896640 - JBpmObjectMapper doesn't handle missing variables properly
JBpmObjectMapper doesn't handle missing variables properly
Product: JBoss Enterprise SOA Platform 5
Classification: JBoss
Component: JBossESB (Show other bugs)
5.3.0 GA
Unspecified Unspecified
unspecified Severity high
: ER4
: 5.3.1
Assigned To: tcunning
Marek Baluch
Depends On: 896634
  Show dependency treegraph
Reported: 2013-01-17 11:35 EST by Rick Wagner
Modified: 2018-03-23 17:30 EDT (History)
6 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
If one of the jBPM variables was missing when mapping from jBPM to ESB an exception was thrown. Now if a jBPM variable is missing (has a null value), the user will receive a log warning, not an exception.
Story Points: ---
Clone Of: 896634
Last Closed:
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

External Trackers
Tracker ID Priority Status Summary Last Updated
JBoss Issue Tracker JBESB-3896 Major Open JBpmObjectMapper doesn't appear to handle missing variables properly 2013-12-06 16:22:23 EST

  None (edit)
Description Rick Wagner 2013-01-17 11:35:01 EST
+++ This bug was initially created as a clone of Bug #896634 +++

Description of problem:

Customer has raised the point that JBpmObjectMapper doesn't make it to what appears to be the intended log statement when a jBPM-side variable is not present.

This can be validated by inserting the following method into JBpmObjectMapperUnitTest.java:

// Same as existing test, just commented out setting v1.

	public void testMissingObject() throws Exception
	// Things to look for:
	// 1) If the variable does not exist in the jbpm variable map, the execution context is tested, but if not present there, an exception is thrown.
        // It looks like the intention was to arrive at "log.warn("The object " + mapping.getBpm() + " is null and cannot not be set on the message")"
        SAXReader reader = new SAXReader();
        Document document = reader.read(this.getClass().getResourceAsStream("/" + PROCESS_DEF_XML));
        Element element = document.getRootElement();
        DefaultElement bpmToEsbVars = (DefaultElement) element.element("start-state").element("transition").element("action").element("bpmToEsbVars");

		String helloWorldTokenScope  = "Hello world token scope";
        String helloWorldGlobalScope = "Hello world process-instance scope";
        TestJBPMVariable objectTokenScope = new TestJBPMVariable("Object token scope") ;
        TestJBPMVariable objectGlobalScope = new TestJBPMVariable("Object global scope") ;

		Token token = processInstance.getRootToken();
        // Don't set v1, see what happens
        //processInstance.getContextInstance().setVariable("v1", helloWorldTokenScope, token);
        processInstance.getContextInstance().setVariable("g2", helloWorldGlobalScope);
        processInstance.getContextInstance().setVariable("h3", objectTokenScope, token);
        processInstance.getContextInstance().setVariable("i4", objectGlobalScope);
        ExecutionContext executionContext = new ExecutionContext(token);

        JBpmObjectMapper mapper = new JBpmObjectMapper();
        Message message = mapper.mapFromJBpmToEsbMessage(bpmToEsbVars, Boolean.FALSE, executionContext);

        assertEquals(objectTokenScope.getInternal(), String.valueOf(message.getBody().get("esbObj3")));
        assertEquals(objectGlobalScope.getInternal(), String.valueOf(message.getBody().get("esbObj4")));
Comment 1 Marek Baluch 2013-02-01 07:13:07 EST
Unit Test Passed.
Comment 2 Marek Baluch 2013-02-04 03:13:36 EST
Tested also on bpm_orchestration1. Added

    <!-- ... -->
    <mapping bpm="theBody1" esb="BODY_CONTENT1"/>

to the process definition. The output of the process contained the following warning and no exception.

09:08:23,897 WARN  [JBpmObjectMapper] The object theBody1 is null and cannot not be set on the message

Note You need to log in before you can comment on or make changes to this bug.