Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,9 @@ public ResponseEntity<List<Task>> batchPoll(
@RequestParam(value = "domain", required = false) String domain,
@RequestParam(value = "count", defaultValue = "1") int count,
@RequestParam(value = "timeout", defaultValue = "100") int timeout) {
// for backwards compatibility with 2.x client which expects a 204 when no Task is found
return Optional.ofNullable(
taskService.batchPoll(taskType, workerId, domain, count, timeout))
.filter(tasks -> !tasks.isEmpty())
.map(ResponseEntity::ok)
.orElse(ResponseEntity.noContent().build());
List<Task> tasks = taskService.batchPoll(taskType, workerId, domain, count, timeout);
// Return empty list instead of 204 to avoid NPE in client libraries
return ResponseEntity.ok(tasks != null ? tasks : List.of());
}

@PostMapping(produces = TEXT_PLAIN_VALUE)
Expand Down
Loading