You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@hbase.apache.org by "Andrew Purtell (JIRA)" <ji...@apache.org> on 2011/07/19 01:32:57 UTC
[jira] [Created] (HBASE-4116) [stargate]
StringIndexOutOfBoundsException in row spec parse
[stargate] StringIndexOutOfBoundsException in row spec parse
------------------------------------------------------------
Key: HBASE-4116
URL: https://issues.apache.org/jira/browse/HBASE-4116
Project: HBase
Issue Type: Bug
Reporter: Andrew Purtell
Assignee: Andrew Purtell
Fix For: 0.90.4, 0.92.0
>From user@hbase, Allan Yan writes:
There might be a bug for REST web service to get rows with given startRow and endRow.
For example, to get a list of rows with startRow=testrow1, endRow=testrow2, I send GET request:
curl http://localhost:8123/TestRowResource/testrow1,testrow2/a:1
And got StringIndexOutOfBoundsException.
This was because in the RowSpec.java, parseRowKeys method, startRow value was changed:
{code}
startRow = sb.toString();
int idx = startRow.indexOf(',');
if (idx != -1) {
startRow = URLDecoder.decode(startRow.substring(0, idx),
HConstants.UTF8_ENCODING);
endRow = URLDecoder.decode(startRow.substring(idx + 1),
HConstants.UTF8_ENCODING);
} else {
startRow = URLDecoder.decode(startRow, HConstants.UTF8_ENCODING);
}
{code}
After change to this, it works:
{code}
String row = sb.toString();
int idx = row.indexOf(',');
if (idx != -1) {
startRow = URLDecoder.decode(row.substring(0, idx),
HConstants.UTF8_ENCODING);
endRow = URLDecoder.decode(row.substring(idx + 1),
HConstants.UTF8_ENCODING);
} else {
startRow = URLDecoder.decode(row, HConstants.UTF8_ENCODING);
}
{code}
I've also created a unit test method in TestRowResource.java,
{code}
@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());
}
}
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());
}
{code}
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Resolved] (HBASE-4116) [stargate]
StringIndexOutOfBoundsException in row spec parse
Posted by "Andrew Purtell (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/HBASE-4116?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Andrew Purtell resolved HBASE-4116.
-----------------------------------
Resolution: Fixed
Fix Version/s: 0.90.4
Assignee: (was: Andrew Purtell)
Committed to 0.90 branch and trunk. All tests pass locally, including new test.
> [stargate] StringIndexOutOfBoundsException in row spec parse
> ------------------------------------------------------------
>
> Key: HBASE-4116
> URL: https://issues.apache.org/jira/browse/HBASE-4116
> Project: HBase
> Issue Type: Bug
> Reporter: Andrew Purtell
> Fix For: 0.90.4, 0.94.0
>
> Attachments: HBASE-4116.patch
>
>
> From user@hbase, Allan Yan writes:
> There might be a bug for REST web service to get rows with given startRow and endRow.
> For example, to get a list of rows with startRow=testrow1, endRow=testrow2, I send GET request:
> curl http://localhost:8123/TestRowResource/testrow1,testrow2/a:1
> And got StringIndexOutOfBoundsException.
> This was because in the RowSpec.java, parseRowKeys method, startRow value was changed:
> {code}
> startRow = sb.toString();
> int idx = startRow.indexOf(',');
> if (idx != -1) {
> startRow = URLDecoder.decode(startRow.substring(0, idx),
> HConstants.UTF8_ENCODING);
> endRow = URLDecoder.decode(startRow.substring(idx + 1),
> HConstants.UTF8_ENCODING);
> } else {
> startRow = URLDecoder.decode(startRow, HConstants.UTF8_ENCODING);
> }
> {code}
> After change to this, it works:
> {code}
> String row = sb.toString();
> int idx = row.indexOf(',');
> if (idx != -1) {
> startRow = URLDecoder.decode(row.substring(0, idx),
> HConstants.UTF8_ENCODING);
> endRow = URLDecoder.decode(row.substring(idx + 1),
> HConstants.UTF8_ENCODING);
> } else {
> startRow = URLDecoder.decode(row, HConstants.UTF8_ENCODING);
> }
> {code}
> I've also created a unit test method in TestRowResource.java,
> {code}
> @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());
> }
> }
> 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());
> }
> {code}
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Commented] (HBASE-4116) [stargate]
StringIndexOutOfBoundsException in row spec parse
Posted by "Hudson (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/HBASE-4116?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13070082#comment-13070082 ]
Hudson commented on HBASE-4116:
-------------------------------
Integrated in HBase-TRUNK #2048 (See [https://builds.apache.org/job/HBase-TRUNK/2048/])
HBASE-4116 [stargate] StringIndexOutOfBoundsException in row spec parse
apurtell :
Files :
* /hbase/trunk/src/test/java/org/apache/hadoop/hbase/rest/TestRowResource.java
* /hbase/trunk/CHANGES.txt
* /hbase/trunk/src/main/java/org/apache/hadoop/hbase/rest/RowSpec.java
> [stargate] StringIndexOutOfBoundsException in row spec parse
> ------------------------------------------------------------
>
> Key: HBASE-4116
> URL: https://issues.apache.org/jira/browse/HBASE-4116
> Project: HBase
> Issue Type: Bug
> Reporter: Andrew Purtell
> Fix For: 0.90.4, 0.94.0
>
> Attachments: HBASE-4116.patch
>
>
> From user@hbase, Allan Yan writes:
> There might be a bug for REST web service to get rows with given startRow and endRow.
> For example, to get a list of rows with startRow=testrow1, endRow=testrow2, I send GET request:
> curl http://localhost:8123/TestRowResource/testrow1,testrow2/a:1
> And got StringIndexOutOfBoundsException.
> This was because in the RowSpec.java, parseRowKeys method, startRow value was changed:
> {code}
> startRow = sb.toString();
> int idx = startRow.indexOf(',');
> if (idx != -1) {
> startRow = URLDecoder.decode(startRow.substring(0, idx),
> HConstants.UTF8_ENCODING);
> endRow = URLDecoder.decode(startRow.substring(idx + 1),
> HConstants.UTF8_ENCODING);
> } else {
> startRow = URLDecoder.decode(startRow, HConstants.UTF8_ENCODING);
> }
> {code}
> After change to this, it works:
> {code}
> String row = sb.toString();
> int idx = row.indexOf(',');
> if (idx != -1) {
> startRow = URLDecoder.decode(row.substring(0, idx),
> HConstants.UTF8_ENCODING);
> endRow = URLDecoder.decode(row.substring(idx + 1),
> HConstants.UTF8_ENCODING);
> } else {
> startRow = URLDecoder.decode(row, HConstants.UTF8_ENCODING);
> }
> {code}
> I've also created a unit test method in TestRowResource.java,
> {code}
> @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());
> }
> }
> 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());
> }
> {code}
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Updated] (HBASE-4116) [stargate]
StringIndexOutOfBoundsException in row spec parse
Posted by "Andrew Purtell (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/HBASE-4116?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Andrew Purtell updated HBASE-4116:
----------------------------------
Attachment: HBASE-4116.patch
Converted Allan's description into a patch.
> [stargate] StringIndexOutOfBoundsException in row spec parse
> ------------------------------------------------------------
>
> Key: HBASE-4116
> URL: https://issues.apache.org/jira/browse/HBASE-4116
> Project: HBase
> Issue Type: Bug
> Reporter: Andrew Purtell
> Assignee: Andrew Purtell
> Fix For: 0.94.0
>
> Attachments: HBASE-4116.patch
>
>
> From user@hbase, Allan Yan writes:
> There might be a bug for REST web service to get rows with given startRow and endRow.
> For example, to get a list of rows with startRow=testrow1, endRow=testrow2, I send GET request:
> curl http://localhost:8123/TestRowResource/testrow1,testrow2/a:1
> And got StringIndexOutOfBoundsException.
> This was because in the RowSpec.java, parseRowKeys method, startRow value was changed:
> {code}
> startRow = sb.toString();
> int idx = startRow.indexOf(',');
> if (idx != -1) {
> startRow = URLDecoder.decode(startRow.substring(0, idx),
> HConstants.UTF8_ENCODING);
> endRow = URLDecoder.decode(startRow.substring(idx + 1),
> HConstants.UTF8_ENCODING);
> } else {
> startRow = URLDecoder.decode(startRow, HConstants.UTF8_ENCODING);
> }
> {code}
> After change to this, it works:
> {code}
> String row = sb.toString();
> int idx = row.indexOf(',');
> if (idx != -1) {
> startRow = URLDecoder.decode(row.substring(0, idx),
> HConstants.UTF8_ENCODING);
> endRow = URLDecoder.decode(row.substring(idx + 1),
> HConstants.UTF8_ENCODING);
> } else {
> startRow = URLDecoder.decode(row, HConstants.UTF8_ENCODING);
> }
> {code}
> I've also created a unit test method in TestRowResource.java,
> {code}
> @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());
> }
> }
> 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());
> }
> {code}
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira