diff --git a/hbase-rest/src/main/java/org/apache/hadoop/hbase/rest/MultiRowResource.java b/hbase-rest/src/main/java/org/apache/hadoop/hbase/rest/MultiRowResource.java index b82cd700c21..6e0e701ea7a 100644 --- a/hbase-rest/src/main/java/org/apache/hadoop/hbase/rest/MultiRowResource.java +++ b/hbase-rest/src/main/java/org/apache/hadoop/hbase/rest/MultiRowResource.java @@ -92,7 +92,7 @@ public class MultiRowResource extends ResourceBase implements Constants { ResultGenerator.fromRowSpec(this.tableResource.getName(), rowSpec, null, !params.containsKey(NOCACHE_PARAM_NAME)); Cell value = null; - RowModel rowModel = new RowModel(rk); + RowModel rowModel = new RowModel(rowSpec.getRow()); if (generator.hasNext()) { while ((value = generator.next()) != null) { rowModel.addCell(new CellModel(CellUtil.cloneFamily(value), CellUtil diff --git a/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/TestMultiRowResource.java b/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/TestMultiRowResource.java index e58be134bf7..7c44e4b6650 100644 --- a/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/TestMultiRowResource.java +++ b/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/TestMultiRowResource.java @@ -236,5 +236,37 @@ public class TestMultiRowResource { client.delete(row_5_url, extraHdr); } + @Test + public void testMultiCellGetWithColsInQueryPathJSON() throws IOException, JAXBException { + String row_5_url = "/" + TABLE + "/" + ROW_1 + "/" + COLUMN_1; + String row_6_url = "/" + TABLE + "/" + ROW_2 + "/" + COLUMN_2; + + StringBuilder path = new StringBuilder(); + path.append("/"); + path.append(TABLE); + path.append("/multiget/?row="); + path.append(ROW_1); + path.append("/"); + path.append(COLUMN_1); + path.append("&row="); + path.append(ROW_2); + path.append("/"); + path.append(COLUMN_1); + + client.post(row_5_url, Constants.MIMETYPE_BINARY, Bytes.toBytes(VALUE_1), extraHdr); + client.post(row_6_url, Constants.MIMETYPE_BINARY, Bytes.toBytes(VALUE_2), extraHdr); + + Response response = client.get(path.toString(), Constants.MIMETYPE_JSON); + assertEquals(200, response.getCode()); + ObjectMapper mapper = new JacksonJaxbJsonProvider().locateMapper( + CellSetModel.class, MediaType.APPLICATION_JSON_TYPE); + CellSetModel cellSet = mapper.readValue(response.getBody(), CellSetModel.class); + assertEquals(1, cellSet.getRows().size()); + assertEquals(ROW_1, Bytes.toString(cellSet.getRows().get(0).getKey())); + assertEquals(VALUE_1, Bytes.toString(cellSet.getRows().get(0).getCells().get(0).getValue())); + + client.delete(row_5_url, extraHdr); + client.delete(row_6_url, extraHdr); + } }