HBASE-17603 REST API for scan should return 404 when table does not exist
This commit is contained in:
parent
810427b950
commit
44f063350b
|
@ -33,11 +33,11 @@ import javax.ws.rs.core.UriInfo;
|
||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
|
||||||
import org.apache.hadoop.hbase.classification.InterfaceAudience;
|
|
||||||
import org.apache.hadoop.hbase.Cell;
|
import org.apache.hadoop.hbase.Cell;
|
||||||
import org.apache.hadoop.hbase.CellUtil;
|
import org.apache.hadoop.hbase.CellUtil;
|
||||||
import org.apache.hadoop.hbase.KeyValue;
|
import org.apache.hadoop.hbase.KeyValue;
|
||||||
|
import org.apache.hadoop.hbase.TableNotFoundException;
|
||||||
|
import org.apache.hadoop.hbase.classification.InterfaceAudience;
|
||||||
import org.apache.hadoop.hbase.rest.model.CellModel;
|
import org.apache.hadoop.hbase.rest.model.CellModel;
|
||||||
import org.apache.hadoop.hbase.rest.model.CellSetModel;
|
import org.apache.hadoop.hbase.rest.model.CellSetModel;
|
||||||
import org.apache.hadoop.hbase.rest.model.RowModel;
|
import org.apache.hadoop.hbase.rest.model.RowModel;
|
||||||
|
@ -106,6 +106,14 @@ public class ScannerInstanceResource extends ResourceBase {
|
||||||
return Response.status(Response.Status.GONE)
|
return Response.status(Response.Status.GONE)
|
||||||
.type(MIMETYPE_TEXT).entity("Gone" + CRLF)
|
.type(MIMETYPE_TEXT).entity("Gone" + CRLF)
|
||||||
.build();
|
.build();
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
Throwable t = e.getCause();
|
||||||
|
if (t instanceof TableNotFoundException) {
|
||||||
|
return Response.status(Response.Status.NOT_FOUND)
|
||||||
|
.type(MIMETYPE_TEXT).entity("Not found" + CRLF)
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
throw e;
|
||||||
}
|
}
|
||||||
if (value == null) {
|
if (value == null) {
|
||||||
if (LOG.isTraceEnabled()) {
|
if (LOG.isTraceEnabled()) {
|
||||||
|
|
|
@ -24,10 +24,12 @@ import java.util.Iterator;
|
||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
import org.apache.hadoop.hbase.classification.InterfaceAudience;
|
|
||||||
import org.apache.hadoop.hbase.Cell;
|
import org.apache.hadoop.hbase.Cell;
|
||||||
import org.apache.hadoop.hbase.KeyValue;
|
import org.apache.hadoop.hbase.KeyValue;
|
||||||
|
import org.apache.hadoop.hbase.TableNotEnabledException;
|
||||||
|
import org.apache.hadoop.hbase.TableNotFoundException;
|
||||||
import org.apache.hadoop.hbase.UnknownScannerException;
|
import org.apache.hadoop.hbase.UnknownScannerException;
|
||||||
|
import org.apache.hadoop.hbase.classification.InterfaceAudience;
|
||||||
import org.apache.hadoop.hbase.client.Result;
|
import org.apache.hadoop.hbase.client.Result;
|
||||||
import org.apache.hadoop.hbase.client.ResultScanner;
|
import org.apache.hadoop.hbase.client.ResultScanner;
|
||||||
import org.apache.hadoop.hbase.client.Scan;
|
import org.apache.hadoop.hbase.client.Scan;
|
||||||
|
@ -169,6 +171,10 @@ public class ScannerResultGenerator extends ResultGenerator {
|
||||||
result = scanner.next();
|
result = scanner.next();
|
||||||
} catch (UnknownScannerException e) {
|
} catch (UnknownScannerException e) {
|
||||||
throw new IllegalArgumentException(e);
|
throw new IllegalArgumentException(e);
|
||||||
|
} catch (TableNotEnabledException tnee) {
|
||||||
|
throw new IllegalStateException(tnee);
|
||||||
|
} catch (TableNotFoundException tnfe) {
|
||||||
|
throw new IllegalArgumentException(tnfe);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
LOG.error(StringUtils.stringifyException(e));
|
LOG.error(StringUtils.stringifyException(e));
|
||||||
}
|
}
|
||||||
|
|
|
@ -358,6 +358,9 @@ public class TestScannerResource {
|
||||||
byte[] body = Bytes.toBytes(writer.toString());
|
byte[] body = Bytes.toBytes(writer.toString());
|
||||||
Response response = client.put("/" + NONEXISTENT_TABLE +
|
Response response = client.put("/" + NONEXISTENT_TABLE +
|
||||||
"/scanner", Constants.MIMETYPE_XML, body);
|
"/scanner", Constants.MIMETYPE_XML, body);
|
||||||
|
String scannerURI = response.getLocation();
|
||||||
|
assertNotNull(scannerURI);
|
||||||
|
response = client.get(scannerURI, Constants.MIMETYPE_XML);
|
||||||
assertEquals(response.getCode(), 404);
|
assertEquals(response.getCode(), 404);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue