NullPointerException in ContextInstance.setVariable(java.lang.String name,
java.lang.Object value) method.
----------------------------------------------------------------------------------------------------------
Key: JBPM-964
URL:
http://jira.jboss.com/jira/browse/JBPM-964
Project: JBoss jBPM
Issue Type: Bug
Components: Core Engine
Affects Versions: jBPM jPDL 3.2
Environment: Windows XP SP2, jbpm-jpdl-3.2.GA
Reporter: Vt Ysh
Assigned To: Tom Baeyens
Priority: Trivial
NullPointerException occurs when trying to set variable value of byte[] type in
ContextInstance. Error happens only in one case, then value is not null and has zero
length
Here is a junit TestCase which represents an error
import junit.framework.TestCase;
import org.jbpm.context.exe.ContextInstance;
import org.jbpm.graph.def.ProcessDefinition;
import org.jbpm.graph.exe.ProcessInstance;
public class ContextTest extends TestCase {
public void testContext() {
ProcessDefinition processDefinition = ProcessDefinition.parseXmlString(
"<process-definition>" +
" <start-state>" +
" <transition to='s' />" +
" </start-state>" +
" <state name='s'>" +
" <transition to='end' />" +
" </state>" +
" <end-state name='end' />" +
"</process-definition>"
);
ProcessInstance processInstance =
new ProcessInstance(processDefinition);
ContextInstance contextInstance =
processInstance.getContextInstance();
try
{
contextInstance.setVariable("test", new byte[0]);
fail("Should raise NullPointer exception");
}catch(NullPointerException e)
{
e.printStackTrace();
}
processInstance.signal();
}
}
Console output:
java.lang.NullPointerException
at java.util.ArrayList.<init>(ArrayList.java:133)
at org.jbpm.bytes.ByteArray.<init>(ByteArray.java:60)
at
org.jbpm.context.log.variableinstance.ByteArrayUpdateLog.<init>(ByteArrayUpdateLog.java:41)
at
org.jbpm.context.exe.variableinstance.ByteArrayInstance.setObject(ByteArrayInstance.java:44)
at org.jbpm.context.exe.VariableInstance.setValue(VariableInstance.java:137)
at org.jbpm.context.exe.VariableInstance.create(VariableInstance.java:74)
at org.jbpm.context.exe.VariableContainer.setVariableLocally(VariableContainer.java:157)
at org.jbpm.context.exe.VariableContainer.setVariable(VariableContainer.java:45)
at org.jbpm.context.exe.ContextInstance.setVariable(ContextInstance.java:166)
at org.jbpm.context.exe.ContextInstance.setVariable(ContextInstance.java:156)
...
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://jira.jboss.com/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira