Bug 1272292 - REST task complete command is handled by injectedTaskService
REST task complete command is handled by injectedTaskService
Status: CLOSED CURRENTRELEASE
Product: JBoss BPMS Platform 6
Classification: JBoss
Component: Business Central (Show other bugs)
6.0.3
Unspecified Unspecified
unspecified Severity high
: ---
: ---
Assigned To: Marco Rietveld
Lukáš Petrovický
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2015-10-15 22:01 EDT by Toshiya Kobayashi
Modified: 2016-09-20 01:06 EDT (History)
1 user (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2015-10-15 22:04:06 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Toshiya Kobayashi 2015-10-15 22:01:00 EDT
Description of problem:

org.kie.remote.services.cdi.ProcessRequestBean.java
=====
    private Object doTaskOperation(Long taskId, String deploymentId, Long processInstanceId, Task task, TaskCommand<?> cmd) { 
        boolean onDeployment = false;
        if( AcceptedCommands.TASK_COMMANDS_THAT_INFLUENCE_KIESESSION.contains(cmd.getClass()) )  {
           onDeployment = true;
        }

...

        if( ! onDeployment ) { 
            return ((InternalTaskService) injectedTaskService).execute(cmd);
        } else {
...
=====

It tries to detect TASK_COMMANDS_THAT_INFLUENCE_KIESESSION which includes CompleteTaskCommand.class but actually, the coming command is "org.jbpm.services.task.commands.CompositeCommand" which has a CompleteTaskCommand as mainCommand. Hence it will use injectedTaskService eventually.

In this case,
- Singleton : SynchronizedTaskService is not used so it will potentially hit JBPM-4249 
- PerProcessInstance : It still works thanks to ExternalTaskEventListener but may have a risk as it's not a recommended usage.

Additional info:

This part is rewritten in BPMS 6.1.0 and not an issue any longer. I filed this BZ just for record.
Comment 1 Toshiya Kobayashi 2015-10-15 22:02:59 EDT
Fix proposal:
============
diff --git a/kie-remote/kie-services-remote/src/main/java/org/kie/remote/services/cdi/ProcessRequestBean.java b/kie-remote/kie-services-remote/src/main/java/org/kie/remote/serv
index 8fbfb1b..e729166 100644
--- a/kie-remote/kie-services-remote/src/main/java/org/kie/remote/services/cdi/ProcessRequestBean.java
+++ b/kie-remote/kie-services-remote/src/main/java/org/kie/remote/services/cdi/ProcessRequestBean.java
@@ -14,6 +14,7 @@ import javax.persistence.PersistenceUnit;
 import org.jbpm.process.audit.AuditLogService;
 import org.jbpm.process.audit.JPAAuditLogService;
 import org.jbpm.process.audit.command.AuditCommand;
+import org.jbpm.services.task.commands.CompositeCommand;
 import org.jbpm.services.task.commands.GetContentCommand;
 import org.jbpm.services.task.commands.GetTaskCommand;
 import org.jbpm.services.task.commands.GetTaskContentCommand;
@@ -236,6 +237,12 @@ public class ProcessRequestBean {
         boolean onDeployment = false;
         if( AcceptedCommands.TASK_COMMANDS_THAT_INFLUENCE_KIESESSION.contains(cmd.getClass()) )  {
            onDeployment = true;
+        } else if (cmd instanceof CompositeCommand) {
+            TaskCommand mainCommand = ((CompositeCommand)cmd).getMainCommand();
+            if( AcceptedCommands.TASK_COMMANDS_THAT_INFLUENCE_KIESESSION.contains(mainCommand.getClass()) )  {
+                System.out.println("doTaskOperation() : mainCommand = " + mainCommand);
+                onDeployment = true;
+            }
         }
       
         // take care of serialization
===============
Comment 2 Toshiya Kobayashi 2015-10-15 22:04:06 EDT
Closed as it's already fixed in BPMS 6.1.0.

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