HBASE-24481 REST - Fix incorrect response code of get-regions in rest api

Closes #2425

Signed-off-by: Viraj Jasani <vjasani@apache.org>
This commit is contained in:
KevinSmile 2020-09-19 19:45:10 +05:30 committed by Viraj Jasani
parent e1fc3c4fd0
commit 20d0a32691
No known key found for this signature in database
GPG Key ID: B3D6C0B41C8ADFD5
2 changed files with 12 additions and 0 deletions

View File

@ -77,6 +77,9 @@ public class RegionsResource extends ResourceBase {
servlet.getMetrics().incrementRequests(1);
try {
TableName tableName = TableName.valueOf(tableResource.getName());
if (!tableResource.exists()) {
throw new TableNotFoundException(tableName);
}
TableInfoModel model = new TableInfoModel(tableName.getNameAsString());
Connection connection = ConnectionFactory.createConnection(servlet.getConfiguration());

View File

@ -257,4 +257,13 @@ public class TestTableResource {
checkTableInfo(model);
}
@Test
public void testTableNotFound() throws IOException {
String notExistTable = "notexist";
Response response1 = client.get("/" + notExistTable + "/schema", Constants.MIMETYPE_JSON);
assertEquals(404, response1.getCode());
Response response2 = client.get("/" + notExistTable + "/regions", Constants.MIMETYPE_XML);
assertEquals(404, response2.getCode());
}
}