AnsweredAssumed Answered

TaskEntity.getCandidates() NPE

Question asked by arkadi on Jul 1, 2011
Latest reply on Jul 4, 2011 by arkadi
I'm trying to show task's candidate information in the GUI by invoking TaskEntity.getCandidates() in the following piece of code but then only NPE comes out

Caused by: java.lang.NullPointerException
    at org.activiti.engine.impl.persistence.entity.TaskEntity.getIdentityLinks(TaskEntity.java:339)
    at org.activiti.engine.impl.persistence.entity.TaskEntity.getCandidates(TaskEntity.java:281)

Task t = engine.getTaskService()
    .createTaskQuery()
    .taskId(id).singleResult();
String names = assignee(t);

String assignee(Task task) {
    String assignee = task.getAssignee();
    if (assignee != null)
        return user(assignee);
    if (!(task instanceof TaskEntity))
        return null;
    List<String> candidates = new ArrayList<String>();
    for (IdentityLink c : ((TaskEntity) task).getCandidates()) {
        if (c.getGroupId() != null)
            candidates.add(group(c.getGroupId()));
        else if (c.getUserId() != null)
            candidates.add(user(c.getUserId()));
    }
    return join(candidates.toArray(strings), ", ");
}
Activiti v5.6.
Is it me doing it wrong or I should raise an issue for that?
The required functionality is not exposed via interface, but as I learned from activiti-rest component, to obtain current process instance diagram you need to cast to impl, so my approach is legal until public API is created, I believe.

Outcomes