Skip to content

Commit

Permalink
Fix issue conductor-oss#38 : Return 204 instead of 404 for /poll end…
Browse files Browse the repository at this point in the history
…points handling non-existent tasks
  • Loading branch information
Vamshi Gopari committed Mar 4, 2024
1 parent 8bf7e90 commit b47d627
Showing 1 changed file with 3 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public ResponseEntity<Task> poll(
// for backwards compatibility with 2.x client which expects a 204 when no Task is found
return Optional.ofNullable(taskService.poll(taskType, workerId, domain))
.map(ResponseEntity::ok)
.orElseThrow(() -> new NotFoundException("Poll not found for Task Type: %s", taskType));
.orElse(ResponseEntity.noContent().build());
}

@GetMapping("/poll/batch/{tasktype}")
Expand All @@ -72,11 +72,10 @@ public ResponseEntity<List<Task>> batchPoll(
@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))
return Optional.ofNullable(taskService.batchPoll(taskType, workerId, domain, count, timeout))
.filter(tasks -> !tasks.isEmpty())
.map(ResponseEntity::ok)
.orElseThrow(() -> new NotFoundException("Batch Poll not found for Task Type: %s", taskType));
.orElse(ResponseEntity.noContent().build());
}

@PostMapping(produces = TEXT_PLAIN_VALUE)
Expand Down

0 comments on commit b47d627

Please sign in to comment.