cancel
Showing results for 
Search instead for 
Did you mean: 

Passing null to TaskQuery.processInstanceId()

cmaron
Champ in-the-making
Champ in-the-making
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();
1 REPLY 1

cmaron
Champ in-the-making
Champ in-the-making
After just looking at TaskQueryImpl, it looks like most of the functions do check for null. I'm guessing processInstanceId() does not because tasks can exist outside of a process instance? If this is the case, sorry to spam the forums!