[jboss-jira] [JBoss JIRA] Created: (JBPM-750) NPE on TaskInstance.java on end() when TaskInstance created manually and no Task is assigned

Uhyon Chung (JIRA) jira-events at jboss.com
Fri Sep 15 02:37:35 EDT 2006


NPE on TaskInstance.java on end() when TaskInstance created manually and no Task is assigned
--------------------------------------------------------------------------------------------

                 Key: JBPM-750
                 URL: http://jira.jboss.com/jira/browse/JBPM-750
             Project: JBoss jBPM
          Issue Type: Bug
          Components: Core Engine
    Affects Versions:  jBPM 3.1.2
         Environment: All
            Reporter: Uhyon Chung
         Assigned To: Tom Baeyens


When you create a new TaskInstance manually (from a ActionHandler) without a Task assigned, an NPE occurs in a log statement in the end(Transition) method.

If you take a look at the end method, it seems to allow null tasks, because it checks whether the task is null before execution methods on the task field. However, in the log.debug statement, it does not do this null check, which causes an NPE. I'm not quite sure if having a TaskInstance without a Task is really a good practice, but otherwise I would need to create a Task object and add it to the ProcessDefinition, which is definitely not something I want to be doing since I just want to add a task instance to the user's task list dynamically.

I've created a small fix, and the patch is as follows.I made the patch based on the 3.1.2 on CVS using Eclipse patch.


### Eclipse Workspace Patch 1.0
#P jbpm3
Index: jpdl/jar/src/main/java/org/jbpm/taskmgmt/exe/TaskInstance.java
===================================================================
RCS file: /cvsroot/jbpm/jbpm.3/jpdl/jar/src/main/java/org/jbpm/taskmgmt/exe/TaskInstance.java,v
retrieving revision 1.6
diff -u -r1.6 TaskInstance.java
--- jpdl/jar/src/main/java/org/jbpm/taskmgmt/exe/TaskInstance.java	8 Sep 2006 11:23:07 -0000	1.6
+++ jpdl/jar/src/main/java/org/jbpm/taskmgmt/exe/TaskInstance.java	15 Sep 2006 06:27:07 -0000
@@
         if (transition==null) {
-          log.debug("completion of task '"+task.getName()+"' results in taking the default transition");
+          log.debug("completion of task '"+(task==null?getName():task.getName())+"' results in taking the default transition");
           token.signal();
         } else {
-          log.debug("completion of task '"+task.getName()+"' results in taking transition '"+transition+"'");
+          log.debug("completion of task '"+(task==null?getName():task.getName())+"' results in taking transition '"+transition+"'");
           token.signal(transition);
         }
       }
 -464,10 +464,10 @@
          ) {

-- 
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

        



More information about the jboss-jira mailing list