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>
(cherry picked from commit 85bd8ee)
  • Loading branch information
stoty committed Jun 19, 2024
1 parent 051118d commit 9585ce1
Show file tree
Hide file tree
Showing 2 changed files with 15 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 @@ -387,4 +387,9 @@ public void testTableScanWithTableDisable() throws IOException {
assertTrue("got " + response.getCode(), response.getCode() == 410);
}

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

0 comments on commit 9585ce1

Please sign in to comment.