AnsweredAssumed Answered

Passing null to TaskQuery.processInstanceId()

Question asked by cmaron on Mar 7, 2012
Latest reply on Mar 7, 2012 by cmaron
Hello all,

I noticed an interesting feature when creating a TaskQuery to find all tasks for a given process Id. If I attempt to do so and the string I pass to processInstanceId() is null (like the example below), I am given ALL active tasks rather than an empty set. Is this expected behaviour? I can understand to some extent why it would be, as the functions called on TaskQuery are effectively filtering the results, but I would prefer Activiti yell at me for attempting to do something like this.

Obviously this is not the end of the world in this case as I can make sure to not pass null, but it strikes me as a potential issue in the future. Is there an option I do not know about that will tell Activiti to assume I'm an idiot and check for null values passed to the various query functions?


TaskService taskService = // Get the task service
String processInstanceId = null;
List<Task> tasks = taskService.createTaskQuery().processInstanceId(processInstanceId).list();

Outcomes