Skip to content

Commit

Permalink
differentiate 'too many' vs 'too few' best-effort lookup matches
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewazores committed Aug 21, 2023
1 parent f9a60f0 commit 416c52d
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/main/java/io/cryostat/reports/Reports.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import jakarta.annotation.security.RolesAllowed;
import jakarta.inject.Inject;
import jakarta.inject.Named;
import jakarta.ws.rs.ClientErrorException;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.NotFoundException;
import jakarta.ws.rs.Path;
Expand Down Expand Up @@ -85,9 +86,12 @@ public Response getV1(@RestPath String recordingName) {
String filename = objectName.split("/")[1];
result.put(jvmId, filename);
});
if (result.size() != 1) {
if (result.size() == 0) {
throw new NotFoundException();
}
if (result.size() > 1) {
throw new ClientErrorException(Response.Status.CONFLICT);
}
var entry = result.entrySet().iterator().next();
return Response.status(RestResponse.Status.PERMANENT_REDIRECT)
.location(
Expand Down

0 comments on commit 416c52d

Please sign in to comment.