Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.

Bug 1115085

Summary: PermissionDeniedException after an attempt to automatically claim next task in a swimlane
Product: [Retired] JBoss BPMS Platform 6 Reporter: Tomas Livora <tlivora>
Component: jBPM CoreAssignee: Alessandro Lazarotti <alazarot>
Status: CLOSED EOL QA Contact: Radovan Synek <rsynek>
Severity: low Docs Contact:
Priority: high    
Version: 6.0.2   
Target Milestone: ER2   
Target Release: 6.1.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2020-03-27 20:07:08 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Tomas Livora 2014-07-01 14:15:12 UTC
Description of problem:
Imagine the situation in which there are two tasks in a swimlane and they are assigned to different groups. If a user complete the first one, the engine will try to claim the second one for him. This operation will not be performed, which is correct behavior. However, PermissionDeniedException is present in the log.

Version-Release number of selected component (if applicable):
BPMS 6.0.2 CR2

Steps to Reproduce:
1. Create a new process with a swimlane and two tasks in it.
2. Assign the first task to one group and the second one to another.
3. Create a user who belongs to the group from the first task but not to the group from the second one.
4. Run the process and try to claim-start-complete the first task with the user you have just created.
5. See what will happen before you try to do anything with the second task.

Actual results:
PermissionDeniedException: http://pastebin.test.redhat.com/218851

Expected results:
No exception at all. The engine should not try to claim the task.

Additional info:
This is a residual effect of bug 997139.

Comment 1 Maciej Swiderski 2014-07-02 10:27:51 UTC
actually this is expected behavior as claim operation is attempted by the process logic (work item handler) that has no way to know about group/user relationship and thus rely on task service to perform this check. The exception is logged to at least give a bit of information to administrators why the auto claim operation fail. 

Do you think we should completely hide the exception?

Comment 2 Tomas Livora 2014-07-02 14:53:46 UTC
Maciej, I think hiding the exception is not a good idea. We should try to avoid it. I have just had a look at LocalHTWorkItemHandler where auto claim is performed. It should be possible to get UserGroupCallback from RuntimeManager and easily check if the user is a member of the group the task is assigned to. Am I right or am I missing something?

Comment 3 Maciej Swiderski 2014-07-02 16:50:08 UTC
Tomas,

this is valid suggestion. The only thing I don't like is that we would duplicate the code responsible for checking if user is allowed to claim a task in the handler itself. But maybe it makes sense to avoid any operation on task service ... I'll need to think about this for a while and do some tests.

Nevertheless, yes, you're right :) Thanks for good input

Comment 4 Maciej Swiderski 2014-07-03 09:50:30 UTC
Tomas,
after looking into this more, the issue is that we cannot always rely on the UserGroupCallback taken from runtime manager as it might not be set in some cases. The most obvious example is business central that utilizes CDI to produce TaskService (with user group callback already configured) and provides that to RuntimeManager that will simply use it. That means the runtime manager itself (to be more precise its runtime environment) will not have user group callback set and by that we cannot make use of it inside the ht work item handler.

So the only way to actually have it reliable is to use commands on task service to verify if user has rights to be assigned to. Though it will mean that if (s)he has rights to do so, it will cost two commands execution which will do the same things in the beginning just to avoid error being written to logs. Personally I think that is not worth it from execution point of view, what's your opinion on this?

Comment 5 Tomas Livora 2014-07-07 11:45:48 UTC
Maciej,
considering your arguments from the previous comment I think the best way how to solve this issue is to catch the exception and write a message to the log explaining that auto-claim has failed. It is not an ideal solution but while this is low-severity BZ and the current behavior does not break any functionality it is better to fix it this way than executing more commands on Task service.

Comment 6 Maciej Swiderski 2014-09-10 13:34:05 UTC
change applied on master, warning will be printed out into logs instead of raw exception.

jbpm
master:
https://github.com/droolsjbpm/jbpm/commit/ec15ecb86d51de01d6ff92e3af1338d90a35ff45

Comment 7 Tomas Livora 2014-12-02 16:10:33 UTC
Verified on BPMS 6.1.0 ER2

No tests have been added as this BZ does not affect functionality. The only thing that has been changed is that now a warning is printed to the output instead of exception stack.