HBASE-22611 Close the DataOutputStream object #325

This commit is contained in:
yuliangwan 2019-06-25 05:14:05 +08:00 committed by Michael Stack
parent 10032a11ba
commit 841b319e4d
1 changed files with 9 additions and 8 deletions

View File

@ -118,16 +118,17 @@ public class RowIndexCodecV1 extends AbstractDataBlockEncoder {
}
boolean includesMvcc = decodingCtx.getHFileContext().isIncludesMvcc();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
DataOutputStream out = new DataOutputStream(baos);
for (Cell cell : kvs) {
KeyValue currentCell = KeyValueUtil.copyToNewKeyValue(cell);
out.write(currentCell.getBuffer(), currentCell.getOffset(),
currentCell.getLength());
if (includesMvcc) {
WritableUtils.writeVLong(out, cell.getSequenceId());
try (DataOutputStream out = new DataOutputStream(baos)) {
for (Cell cell : kvs) {
KeyValue currentCell = KeyValueUtil.copyToNewKeyValue(cell);
out.write(currentCell.getBuffer(), currentCell.getOffset(),
currentCell.getLength());
if (includesMvcc) {
WritableUtils.writeVLong(out, cell.getSequenceId());
}
}
out.flush();
}
out.flush();
return ByteBuffer.wrap(baos.getBuffer(), 0, baos.size());
}
}