HBASE-4116 [stargate] StringIndexOutOfBoundsException in row spec parse
git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1150206 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
4b21f2e32b
commit
72409650d5
@ -171,6 +171,8 @@ Release 0.91.0 - Unreleased
|
||||
HBASE-4127 Don't modify table's name away in HBaseAdmin
|
||||
HBASE-4105 Stargate does not support Content-Type: application/json and
|
||||
Content-Encoding: gzip in parallel
|
||||
HBASE-4116 [stargate] StringIndexOutOfBoundsException in row spec parse
|
||||
(Allan Yan)
|
||||
|
||||
IMPROVEMENTS
|
||||
HBASE-3290 Max Compaction Size (Nicolas Spiegelberg via Stack)
|
||||
|
@ -70,15 +70,15 @@ public class RowSpec {
|
||||
i++;
|
||||
}
|
||||
i++;
|
||||
startRow = sb.toString();
|
||||
String row = startRow = sb.toString();
|
||||
int idx = startRow.indexOf(',');
|
||||
if (idx != -1) {
|
||||
startRow = URLDecoder.decode(startRow.substring(0, idx),
|
||||
startRow = URLDecoder.decode(row.substring(0, idx),
|
||||
HConstants.UTF8_ENCODING);
|
||||
endRow = URLDecoder.decode(startRow.substring(idx + 1),
|
||||
endRow = URLDecoder.decode(row.substring(idx + 1),
|
||||
HConstants.UTF8_ENCODING);
|
||||
} else {
|
||||
startRow = URLDecoder.decode(startRow, HConstants.UTF8_ENCODING);
|
||||
startRow = URLDecoder.decode(row, HConstants.UTF8_ENCODING);
|
||||
}
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
throw new IllegalArgumentException(e);
|
||||
|
@ -46,6 +46,7 @@ import org.apache.hadoop.hbase.rest.model.RowModel;
|
||||
import org.apache.hadoop.hbase.util.Bytes;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
@ -141,6 +142,20 @@ public class TestRowResource {
|
||||
return getValueXML(path.toString());
|
||||
}
|
||||
|
||||
private static Response getValueXML(String table, String startRow,
|
||||
String endRow, String column) throws IOException {
|
||||
StringBuilder path = new StringBuilder();
|
||||
path.append('/');
|
||||
path.append(table);
|
||||
path.append('/');
|
||||
path.append(startRow);
|
||||
path.append(",");
|
||||
path.append(endRow);
|
||||
path.append('/');
|
||||
path.append(column);
|
||||
return getValueXML(path.toString());
|
||||
}
|
||||
|
||||
private static Response getValueXML(String url) throws IOException {
|
||||
Response response = client.get(url, Constants.MIMETYPE_XML);
|
||||
return response;
|
||||
@ -483,4 +498,32 @@ public class TestRowResource {
|
||||
response = deleteRow(TABLE, ROW_2);
|
||||
assertEquals(response.getCode(), 200);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStartEndRowGetPutXML() throws IOException, JAXBException {
|
||||
String[] rows = { ROW_1, ROW_2, ROW_3 };
|
||||
String[] values = { VALUE_1, VALUE_2, VALUE_3 };
|
||||
Response response = null;
|
||||
for (int i = 0; i < rows.length; i++) {
|
||||
response = putValueXML(TABLE, rows[i], COLUMN_1, values[i]);
|
||||
assertEquals(200, response.getCode());
|
||||
checkValueXML(TABLE, rows[i], COLUMN_1, values[i]);
|
||||
}
|
||||
response = getValueXML(TABLE, rows[0], rows[2], COLUMN_1);
|
||||
assertEquals(200, response.getCode());
|
||||
CellSetModel cellSet = (CellSetModel)
|
||||
unmarshaller.unmarshal(new ByteArrayInputStream(response.getBody()));
|
||||
assertEquals(2, cellSet.getRows().size());
|
||||
for (int i = 0; i < cellSet.getRows().size()-1; i++) {
|
||||
RowModel rowModel = cellSet.getRows().get(i);
|
||||
for (CellModel cell: rowModel.getCells()) {
|
||||
assertEquals(COLUMN_1, Bytes.toString(cell.getColumn()));
|
||||
assertEquals(values[i], Bytes.toString(cell.getValue()));
|
||||
}
|
||||
}
|
||||
for (String row : rows) {
|
||||
response = deleteRow(TABLE, row);
|
||||
assertEquals(200, response.getCode());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user