Skip to content

Commit

Permalink
HBASE-28662 Removing missing scanner via REST should return 404 (#5989)
Browse files Browse the repository at this point in the history
Signed-off-by: Duo Zhang <zhangduo@apache.org>
  • Loading branch information
stoty authored Jun 19, 2024
1 parent cd4c5c3 commit 85bd8ee
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,11 @@ public Response getBinary(final @Context UriInfo uriInfo) {
}
servlet.getMetrics().incrementRequests(1);
try {
if (generator == null) {
servlet.getMetrics().incrementFailedGetRequests(1);
return Response.status(Response.Status.NOT_FOUND).type(MIMETYPE_TEXT)
.entity("Not found" + CRLF).build();
}
Cell value = generator.next();
if (value == null) {
if (LOG.isTraceEnabled()) {
Expand Down Expand Up @@ -199,6 +204,11 @@ public Response delete(final @Context UriInfo uriInfo) {
return Response.status(Response.Status.FORBIDDEN).type(MIMETYPE_TEXT)
.entity("Forbidden" + CRLF).build();
}
if (generator == null) {
servlet.getMetrics().incrementFailedDeleteRequests(1);
return Response.status(Response.Status.NOT_FOUND).type(MIMETYPE_TEXT)
.entity("Not found" + CRLF).build();
}
if (ScannerResource.delete(id)) {
servlet.getMetrics().incrementSucessfulDeleteRequests(1);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -393,4 +393,10 @@ public void testTableScanWithTableDisable() throws IOException {
response = client.get(scannerURI, Constants.MIMETYPE_PROTOBUF);
assertEquals(410, response.getCode());
}

@Test
public void deleteNonExistent() throws IOException {
Response response = client.delete("/" + TABLE + "/scanner/NONEXISTENT_SCAN");
assertEquals(404, response.getCode());
}
}

0 comments on commit 85bd8ee

Please sign in to comment.