Skip to content

Commit

Permalink
HBASE-28650 REST multiget endpoint returns 500 error if no rows are s…
Browse files Browse the repository at this point in the history
…pecified (#5999)

Signed-off-by: Duo Zhang <zhangduo@apache.org>
(cherry picked from commit f2b7b77)
  • Loading branch information
stoty committed Jun 18, 2024
1 parent 42ecc23 commit d7b1954
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -98,19 +98,21 @@ public Response get(final @Context UriInfo uriInfo,
parsedParamFilter = pf.parseFilterString(filterBytes);
}
List<RowSpec> rowSpecs = new ArrayList<>();
for (String rk : params.get(ROW_KEYS_PARAM_NAME)) {
RowSpec rowSpec = new RowSpec(rk, keyEncoding);
if (params.containsKey(ROW_KEYS_PARAM_NAME)) {
for (String rk : params.get(ROW_KEYS_PARAM_NAME)) {
RowSpec rowSpec = new RowSpec(rk, keyEncoding);

if (this.versions != null) {
rowSpec.setMaxVersions(this.versions);
}
if (this.versions != null) {
rowSpec.setMaxVersions(this.versions);
}

if (this.columns != null) {
for (int i = 0; i < this.columns.length; i++) {
rowSpec.addColumn(Bytes.toBytes(this.columns[i]));
if (this.columns != null) {
for (int i = 0; i < this.columns.length; i++) {
rowSpec.addColumn(Bytes.toBytes(this.columns[i]));
}
}
rowSpecs.add(rowSpec);
}
rowSpecs.add(rowSpec);
}

MultiRowResultReader reader = new MultiRowResultReader(this.tableResource.getName(), rowSpecs,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,17 @@ public void testMultiCellGetJSONB64() throws IOException {
client.delete(row_6_url, extraHdr);
}

@Test
public void testMultiCellGetNoKeys() throws IOException {
StringBuilder path = new StringBuilder();
path.append("/");
path.append(TABLE);
path.append("/multiget");

Response response = client.get(path.toString(), Constants.MIMETYPE_XML);
assertEquals(404, response.getCode());
}

@Test
public void testMultiCellGetXML() throws IOException {
String row_5_url = "/" + TABLE + "/" + ROW_1 + "/" + COLUMN_1;
Expand Down

0 comments on commit d7b1954

Please sign in to comment.