Skip to content

Commit 25713c9

Browse files
jsimonweblesv
authored andcommitted
Add block to handle null task payload in pull queue REST sample (GoogleCloudPlatform#212)
* Replaced queue.xml with queue.yaml * Add block to handle null payload
1 parent 47ecf80 commit 25713c9

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

taskqueue/pull/src/main/java/TaskQueueSample.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,8 +172,12 @@ private static Tasks getLeasedTasks(Taskqueue taskQueue) throws IOException {
172172
*/
173173
private static void processTask(Task task) {
174174
byte[] payload = Base64.decodeBase64(task.getPayloadBase64());
175-
System.out.println("Payload for the task:");
176-
System.out.println(new String(payload));
175+
if (payload != null) {
176+
System.out.println("Payload for the task:");
177+
System.out.println(new String(payload));
178+
} else {
179+
System.out.println("This task has no payload.");
180+
}
177181
}
178182
/**
179183
* Method that sends a delete request for the specified task object to the taskqueue service.

0 commit comments

Comments
 (0)