diff --git a/src/main/java/org/apache/hadoop/hbase/thrift/ThriftServerRunner.java b/src/main/java/org/apache/hadoop/hbase/thrift/ThriftServerRunner.java index 517854cf67f..99b13924993 100644 --- a/src/main/java/org/apache/hadoop/hbase/thrift/ThriftServerRunner.java +++ b/src/main/java/org/apache/hadoop/hbase/thrift/ThriftServerRunner.java @@ -974,11 +974,11 @@ public class ThriftServerRunner implements Runnable { } else { if(famAndQf.length == 1) { put.add(famAndQf[0], HConstants.EMPTY_BYTE_ARRAY, - m.value != null ? m.value.array() + m.value != null ? getBytes(m.value) : HConstants.EMPTY_BYTE_ARRAY); } else { put.add(famAndQf[0], famAndQf[1], - m.value != null ? m.value.array() + m.value != null ? getBytes(m.value) : HConstants.EMPTY_BYTE_ARRAY); } put.setWriteToWAL(m.writeToWAL); @@ -1032,11 +1032,11 @@ public class ThriftServerRunner implements Runnable { } else { if(famAndQf.length == 1) { put.add(famAndQf[0], HConstants.EMPTY_BYTE_ARRAY, - m.value != null ? m.value.array() + m.value != null ? getBytes(m.value) : HConstants.EMPTY_BYTE_ARRAY); } else { put.add(famAndQf[0], famAndQf[1], - m.value != null ? m.value.array() + m.value != null ? getBytes(m.value) : HConstants.EMPTY_BYTE_ARRAY); } put.setWriteToWAL(m.writeToWAL); @@ -1401,8 +1401,8 @@ public class ThriftServerRunner implements Runnable { return; } for (Map.Entry entry : attributes.entrySet()) { - String name = Bytes.toStringBinary(entry.getKey()); - byte[] value = Bytes.toBytes(entry.getValue()); + String name = Bytes.toStringBinary(getBytes(entry.getKey())); + byte[] value = getBytes(entry.getValue()); op.setAttribute(name, value); } } diff --git a/src/test/java/org/apache/hadoop/hbase/thrift/TestThriftServer.java b/src/test/java/org/apache/hadoop/hbase/thrift/TestThriftServer.java index 444d6d52d7b..9e8b3b239f3 100644 --- a/src/test/java/org/apache/hadoop/hbase/thrift/TestThriftServer.java +++ b/src/test/java/org/apache/hadoop/hbase/thrift/TestThriftServer.java @@ -209,9 +209,13 @@ public class TestThriftServer { * @throws Exception */ public void doTestTableMutations() throws Exception { - // Setup ThriftServerRunner.HBaseHandler handler = new ThriftServerRunner.HBaseHandler(UTIL.getConfiguration()); + doTestTableMutations(handler); + } + + public static void doTestTableMutations(Hbase.Iface handler) throws Exception { + // Setup handler.createTable(tableAname, getColumnDescriptors()); // Apply a few Mutations to rowA @@ -267,7 +271,7 @@ public class TestThriftServer { handler.mutateRow(tableAname, rowAname, mutations, null); TRowResult rowResult3 = handler.getRow(tableAname, rowAname, null).get(0); assertEquals(rowAname, rowResult3.row); - assertEquals(0, rowResult3.columns.get(columnAname).value.array().length); + assertEquals(0, rowResult3.columns.get(columnAname).value.remaining()); // Teardown handler.disableTable(tableAname); @@ -540,7 +544,7 @@ public class TestThriftServer { * (rowB, columnA): place valueC * (rowB, columnB): place valueD */ - private List getBatchMutations() { + private static List getBatchMutations() { List batchMutations = new ArrayList(); // Mutations to rowA. You can't mix delete and put anymore. diff --git a/src/test/java/org/apache/hadoop/hbase/thrift/TestThriftServerCmdLine.java b/src/test/java/org/apache/hadoop/hbase/thrift/TestThriftServerCmdLine.java index 52356b84d1d..f8fcb37a9d0 100644 --- a/src/test/java/org/apache/hadoop/hbase/thrift/TestThriftServerCmdLine.java +++ b/src/test/java/org/apache/hadoop/hbase/thrift/TestThriftServerCmdLine.java @@ -58,7 +58,7 @@ import com.google.common.base.Joiner; @RunWith(Parameterized.class) public class TestThriftServerCmdLine { - public static final Log LOG = + public static final Log LOG = LogFactory.getLog(TestThriftServerCmdLine.class); private final ImplType implType; @@ -71,7 +71,7 @@ public class TestThriftServerCmdLine { private Thread cmdLineThread; private volatile Exception cmdLineException; - + private Exception clientSideException; private ThriftServer thriftServer; @@ -142,7 +142,7 @@ public class TestThriftServerCmdLine { cmdLineThread.start(); } - @Test(timeout=30 * 1000) + @Test(timeout=60 * 1000) public void testRunThriftServer() throws Exception { List args = new ArrayList(); if (implType != null) { @@ -209,6 +209,7 @@ public class TestThriftServerCmdLine { TestThriftServer.doTestTableCreateDrop(client); TestThriftServer.doTestGetRegionInfo(client); TestThriftServer.doTestGetTableRegions(client); + TestThriftServer.doTestTableMutations(client); } finally { sock.close(); }