From c04cad9e7dcf0b0951d4da6deb0ee3c897f8a4e0 Mon Sep 17 00:00:00 2001 From: Andrew Kyle Purtell Date: Thu, 27 Jun 2013 05:05:21 +0000 Subject: [PATCH] HBASE-8811. REST service ignores misspelled 'check' parameter, causing unexpected mutations (Chip Salzenberg and Andrew Purtell) git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1497209 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/hadoop/hbase/rest/RowResource.java | 4 +++- .../hadoop/hbase/rest/TestRowResource.java | 17 +++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/rest/RowResource.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/rest/RowResource.java index c3872511f3a..dda960a427d 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/rest/RowResource.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/rest/RowResource.java @@ -182,7 +182,9 @@ public class RowResource extends ResourceBase { } else if (CHECK_DELETE.equalsIgnoreCase(check)) { return checkAndDelete(model); } else if (check != null && check.length() > 0) { - LOG.warn("Unknown check value: " + check + ", ignored"); + return Response.status(Response.Status.BAD_REQUEST) + .type(MIMETYPE_TEXT).entity("Invalid check value '" + check + "'" + CRLF) + .build(); } HTablePool pool = servlet.getTablePool(); diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/rest/TestRowResource.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/rest/TestRowResource.java index a4b0982021d..47f2f647038 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/rest/TestRowResource.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/rest/TestRowResource.java @@ -699,5 +699,22 @@ public class TestRowResource { } } + @Test + public void testInvalidCheckParam() throws IOException, JAXBException { + CellSetModel cellSetModel = new CellSetModel(); + RowModel rowModel = new RowModel(ROW_1); + rowModel.addCell(new CellModel(Bytes.toBytes(COLUMN_1), + Bytes.toBytes(VALUE_1))); + cellSetModel.addRow(rowModel); + StringWriter writer = new StringWriter(); + marshaller.marshal(cellSetModel, writer); + + final String path = "/" + TABLE + "/" + ROW_1 + "/" + COLUMN_1 + "?check=blah"; + + Response response = client.put(path, Constants.MIMETYPE_XML, + Bytes.toBytes(writer.toString())); + assertEquals(response.getCode(), 400); + } + }