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:
parent
de2f538bc9
commit
7aa36ae10a
|
@ -75,6 +75,9 @@ public class RegionsResource extends ResourceBase {
|
||||||
servlet.getMetrics().incrementRequests(1);
|
servlet.getMetrics().incrementRequests(1);
|
||||||
try {
|
try {
|
||||||
TableName tableName = TableName.valueOf(tableResource.getName());
|
TableName tableName = TableName.valueOf(tableResource.getName());
|
||||||
|
if (!tableResource.exists()) {
|
||||||
|
throw new TableNotFoundException(tableName);
|
||||||
|
}
|
||||||
TableInfoModel model = new TableInfoModel(tableName.getNameAsString());
|
TableInfoModel model = new TableInfoModel(tableName.getNameAsString());
|
||||||
|
|
||||||
List<HRegionLocation> locs;
|
List<HRegionLocation> locs;
|
||||||
|
|
|
@ -261,5 +261,14 @@ public class TestTableResource {
|
||||||
checkTableInfo(model);
|
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());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue