hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From te...@apache.org
Subject hbase git commit: HBASE-17603 REST API for scan should return 404 when table does not exist
Date Mon, 13 Feb 2017 16:40:56 GMT
Repository: hbase
Updated Branches:
  refs/heads/master d40bca436 -> 539f97c02


HBASE-17603 REST API for scan should return 404 when table does not exist


Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/539f97c0
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/539f97c0
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/539f97c0

Branch: refs/heads/master
Commit: 539f97c020718102393e94c7469286d319359f01
Parents: d40bca4
Author: tedyu <yuzhihong@gmail.com>
Authored: Mon Feb 13 08:40:49 2017 -0800
Committer: tedyu <yuzhihong@gmail.com>
Committed: Mon Feb 13 08:40:49 2017 -0800

----------------------------------------------------------------------
 .../hadoop/hbase/rest/ScannerInstanceResource.java      | 12 ++++++++++--
 .../hadoop/hbase/rest/ScannerResultGenerator.java       |  8 +++++++-
 .../apache/hadoop/hbase/rest/TestScannerResource.java   |  3 +++
 3 files changed, 20 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/539f97c0/hbase-rest/src/main/java/org/apache/hadoop/hbase/rest/ScannerInstanceResource.java
----------------------------------------------------------------------
diff --git a/hbase-rest/src/main/java/org/apache/hadoop/hbase/rest/ScannerInstanceResource.java
b/hbase-rest/src/main/java/org/apache/hadoop/hbase/rest/ScannerInstanceResource.java
index 2469faa..49a2ef1 100644
--- a/hbase-rest/src/main/java/org/apache/hadoop/hbase/rest/ScannerInstanceResource.java
+++ b/hbase-rest/src/main/java/org/apache/hadoop/hbase/rest/ScannerInstanceResource.java
@@ -33,11 +33,11 @@ import javax.ws.rs.core.UriInfo;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-
-import org.apache.hadoop.hbase.classification.InterfaceAudience;
 import org.apache.hadoop.hbase.Cell;
 import org.apache.hadoop.hbase.CellUtil;
 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.CellSetModel;
 import org.apache.hadoop.hbase.rest.model.RowModel;
@@ -106,6 +106,14 @@ public class ScannerInstanceResource extends ResourceBase {
         return Response.status(Response.Status.GONE)
           .type(MIMETYPE_TEXT).entity("Gone" + CRLF)
           .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 (LOG.isTraceEnabled()) {

http://git-wip-us.apache.org/repos/asf/hbase/blob/539f97c0/hbase-rest/src/main/java/org/apache/hadoop/hbase/rest/ScannerResultGenerator.java
----------------------------------------------------------------------
diff --git a/hbase-rest/src/main/java/org/apache/hadoop/hbase/rest/ScannerResultGenerator.java
b/hbase-rest/src/main/java/org/apache/hadoop/hbase/rest/ScannerResultGenerator.java
index 9a8ee00..2ddb6c3 100644
--- a/hbase-rest/src/main/java/org/apache/hadoop/hbase/rest/ScannerResultGenerator.java
+++ b/hbase-rest/src/main/java/org/apache/hadoop/hbase/rest/ScannerResultGenerator.java
@@ -24,10 +24,12 @@ import java.util.Iterator;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.apache.hadoop.hbase.classification.InterfaceAudience;
 import org.apache.hadoop.hbase.Cell;
 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.classification.InterfaceAudience;
 import org.apache.hadoop.hbase.client.Result;
 import org.apache.hadoop.hbase.client.ResultScanner;
 import org.apache.hadoop.hbase.client.Scan;
@@ -169,6 +171,10 @@ public class ScannerResultGenerator extends ResultGenerator {
           result = scanner.next();
         } catch (UnknownScannerException e) {
           throw new IllegalArgumentException(e);
+        } catch (TableNotEnabledException tnee) {
+          throw new IllegalStateException(tnee);
+        } catch (TableNotFoundException tnfe) {
+          throw new IllegalArgumentException(tnfe);
         } catch (IOException e) {
           LOG.error(StringUtils.stringifyException(e));
         }

http://git-wip-us.apache.org/repos/asf/hbase/blob/539f97c0/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/TestScannerResource.java
----------------------------------------------------------------------
diff --git a/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/TestScannerResource.java
b/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/TestScannerResource.java
index 3916386..03d367a 100644
--- a/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/TestScannerResource.java
+++ b/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/TestScannerResource.java
@@ -359,6 +359,9 @@ public class TestScannerResource {
     byte[] body = Bytes.toBytes(writer.toString());
     Response response = client.put("/" + NONEXISTENT_TABLE +
       "/scanner", Constants.MIMETYPE_XML, body);
+    String scannerURI = response.getLocation();
+    assertNotNull(scannerURI);
+    response = client.get(scannerURI, Constants.MIMETYPE_XML);
     assertEquals(response.getCode(), 404);
   }
 


Mime
View raw message