Fix NPE on task.thread premature usage in debug message