hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From apurt...@apache.org
Subject svn commit: r1150207 - in /hbase/branches/0.90: CHANGES.txt src/main/java/org/apache/hadoop/hbase/rest/RowSpec.java src/test/java/org/apache/hadoop/hbase/rest/TestRowResource.java
Date Sat, 23 Jul 2011 19:50:32 GMT
Author: apurtell
Date: Sat Jul 23 19:50:31 2011
New Revision: 1150207

URL: http://svn.apache.org/viewvc?rev=1150207&view=rev
Log:
HBASE-4116 [stargate] StringIndexOutOfBoundsException in row spec parse

Modified:
    hbase/branches/0.90/CHANGES.txt
    hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/rest/RowSpec.java
    hbase/branches/0.90/src/test/java/org/apache/hadoop/hbase/rest/TestRowResource.java

Modified: hbase/branches/0.90/CHANGES.txt
URL: http://svn.apache.org/viewvc/hbase/branches/0.90/CHANGES.txt?rev=1150207&r1=1150206&r2=1150207&view=diff
==============================================================================
--- hbase/branches/0.90/CHANGES.txt (original)
+++ hbase/branches/0.90/CHANGES.txt Sat Jul 23 19:50:31 2011
@@ -85,6 +85,8 @@ Release 0.90.4 - Unreleased
    HBASE-4126  Make timeoutmonitor timeout after 30 minutes instead of 3
    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)
 
   IMPROVEMENT
    HBASE-3882  hbase-config.sh needs to be updated so it can auto-detects the

Modified: hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/rest/RowSpec.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/rest/RowSpec.java?rev=1150207&r1=1150206&r2=1150207&view=diff
==============================================================================
--- hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/rest/RowSpec.java (original)
+++ hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/rest/RowSpec.java Sat Jul 23
19:50:31 2011
@@ -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);

Modified: hbase/branches/0.90/src/test/java/org/apache/hadoop/hbase/rest/TestRowResource.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.90/src/test/java/org/apache/hadoop/hbase/rest/TestRowResource.java?rev=1150207&r1=1150206&r2=1150207&view=diff
==============================================================================
--- hbase/branches/0.90/src/test/java/org/apache/hadoop/hbase/rest/TestRowResource.java (original)
+++ hbase/branches/0.90/src/test/java/org/apache/hadoop/hbase/rest/TestRowResource.java Sat
Jul 23 19:50:31 2011
@@ -141,6 +141,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 +497,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());
+    }
+  }
 }



Mime
View raw message