HBASE-21132 return wrong result in rest multiget

This commit is contained in:
Guangxu Cheng 2018-08-30 20:51:41 +08:00
parent fb74f215b4
commit 1eea44c804
2 changed files with 33 additions and 1 deletions

View File

@ -92,7 +92,7 @@ public class MultiRowResource extends ResourceBase implements Constants {
ResultGenerator.fromRowSpec(this.tableResource.getName(), rowSpec, null, ResultGenerator.fromRowSpec(this.tableResource.getName(), rowSpec, null,
!params.containsKey(NOCACHE_PARAM_NAME)); !params.containsKey(NOCACHE_PARAM_NAME));
Cell value = null; Cell value = null;
RowModel rowModel = new RowModel(rk); RowModel rowModel = new RowModel(rowSpec.getRow());
if (generator.hasNext()) { if (generator.hasNext()) {
while ((value = generator.next()) != null) { while ((value = generator.next()) != null) {
rowModel.addCell(new CellModel(CellUtil.cloneFamily(value), CellUtil rowModel.addCell(new CellModel(CellUtil.cloneFamily(value), CellUtil

View File

@ -236,5 +236,37 @@ public class TestMultiRowResource {
client.delete(row_5_url, extraHdr); 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);
}
} }