Details
Description
claim() in the taskservice currently throws a generic ActivitiException when the task was already claimed by someone else:
if(userId != null) {
if (task.getAssignee() != null) {
if(!task.getAssignee().equals(userId)) {
// When the task is already claimed by another user, throw exception. Otherwise, ignore
// this, post-conditions of method already met.
throw new ActivitiException("Task " + taskId + " is already claimed by someone else");
}
} else {
task.setAssignee(userId);
}
} else {
// Task should be assigned to no one
task.setAssignee(null);
}
it seems to me that this is quite a common case, if you have let's say 10 users in a candidate group looking at the same list of tasks it will happen often that you claim something that was already claimed. This is part of common and normal workflow interaction. So why not throw a specific exception 'TaskAlreadyClaimedException' instead, and put the assignee in it so we can display a nice message like 'This task was already claimed by user xyz'.
If this seems reasonable i can provide a quick patch.
Issue Links
- is related to
-
ACT-1274
Remove SEVERE level logging for expected exception in taskservice.claim()
-
I agree with Jorg. This is a common and expected case in a multi-user system. Furthermore, CommandContext.close() (line 121) logs these exceptions at the SEVERE level which is incorrect. Since this is an expected state, these should be logged as INFO or DEBUG only. Better yet, logging could be disabled completely since the exception is re-thrown to the caller. The caller can then decide if this should be logged, and if so, what the appropriate level is.