[
https://issues.apache.org/jira/browse/HBASE-18554?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16200601#comment-16200601
]
Chia-Ping Tsai commented on HBASE-18554:
----------------------------------------
{code}
@Test
public void testWrongRowInAppend() throws Exception {
TableName tableName = TableName.valueOf("testDiffRowAppend");
HTableDescriptor desc = new HTableDescriptor(tableName)
.addFamily(new HColumnDescriptor(FAMILY));
byte[][] splits = new byte[][]{Bytes.toBytes("3")};
TEST_UTIL.getHBaseAdmin().createTable(desc, splits);
Append append = new Append(Bytes.toBytes("1"));
append.add(CellUtil.createCell(Bytes.toBytes("1"), FAMILY, null,
System.currentTimeMillis(),
KeyValue.Type.Put.getCode(), Bytes.toBytes("value")));
append.add(CellUtil.createCell(Bytes.toBytes("5"), FAMILY, null,
System.currentTimeMillis(),
KeyValue.Type.Put.getCode(), Bytes.toBytes("value")));
try (Table t = TEST_UTIL.getConnection().getTable(tableName)) {
t.batch(Arrays.asList(append));
Get g = new Get(Bytes.toBytes("5"));
Result r = t.get(g);
assertFalse(r.isEmpty());
}
}
{code}
User can add a invalid row of cell to the region via {{Append#add}}. Not sure
how dangerous the invalid cell is, but we should protect user from the time
bomb.
> Append#add doesn't check the row of passed cell
> -----------------------------------------------
>
> Key: HBASE-18554
> URL: https://issues.apache.org/jira/browse/HBASE-18554
> Project: HBase
> Issue Type: Bug
> Reporter: Chia-Ping Tsai
> Assignee: Reid Chan
> Labels: beginner
> Attachments: HBASE-18554.master.001.patch,
> HBASE-18554.master.002.patch
>
>
> {code}
> @SuppressWarnings("unchecked")
> public Append add(final Cell cell) {
> // Presume it is KeyValue for now.
> byte [] family = CellUtil.cloneFamily(cell);
> List<Cell> list = this.familyMap.get(family);
> if (list == null) {
> list = new ArrayList<>(1);
> }
> // find where the new entry should be placed in the List
> list.add(cell);
> this.familyMap.put(family, list);
> return this;
> }
> {code}
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)