Skip to content

Commit

Permalink
HBASE-22611 Close the DataOutputStream object #325
Browse files Browse the repository at this point in the history
  • Loading branch information
yuliangwan authored and saintstack committed Jun 24, 2019
1 parent 10032a1 commit 841b319
Showing 1 changed file with 9 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -118,16 +118,17 @@ public ByteBuffer decodeKeyValues(DataInputStream source,
}
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());
}
}
Expand Down

0 comments on commit 841b319

Please sign in to comment.