Prevent NPE in ListTasks

If the show-queue command is executed while an ls-projects command is
executing, NPE occurs in the ListTasks REST API endpoint.

Add a null check to prevent this.

Bug: Issue 3211
Change-Id: Iea0ad5d1336d258ee2cd898eb5488ef610eb7d0c
This commit is contained in:
David Pursehouse
2015-02-26 12:14:56 +09:00
parent 2bb0f3a4da
commit a9c89366a4

View File

@@ -124,7 +124,10 @@ public class ListTasks implements RestReadView<ConfigResource> {
if (task instanceof ProjectTask) {
ProjectTask<?> projectTask = ((ProjectTask<?>) task);
this.projectName = projectTask.getProjectNameKey().get();
Project.NameKey name = projectTask.getProjectNameKey();
if (name != null) {
this.projectName = name.get();
}
this.remoteName = projectTask.getRemoteName();
}
}