Skip to content

Commit

Permalink
FileTransactionStoreManager#closeFile() method remove redundant fileC…
Browse files Browse the repository at this point in the history
…hannel.close() invoke (apache#140)
  • Loading branch information
ykgarfield authored and slievrly committed Jan 17, 2019
1 parent ed4eddb commit 72d238d
Showing 1 changed file with 4 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ public boolean hasRemaining(boolean isHistory) {

} catch (IOException exx) {
} finally {
closeFile(raf, null);
closeFile(raf);
}
return false;
}
Expand Down Expand Up @@ -228,7 +228,7 @@ private List<TransactionWriteStore> parseDataFile(File file, int readSize, long
recoverCurrOffset = fileChannel.position();
}
}
closeFile(raf, fileChannel);
closeFile(raf);
} catch (IOException exx) {
LOGGER.error("file close error," + exx.getMessage());
}
Expand All @@ -241,12 +241,8 @@ private boolean isHisFile(File file) {
return file.getName().endsWith(HIS_DATA_FILENAME_POSTFIX);
}

private void closeFile(RandomAccessFile raf, FileChannel fileChannel) {
private void closeFile(RandomAccessFile raf) {
try {
if (null != fileChannel) {
fileChannel.close();
fileChannel = null;
}
if (null != raf) {
raf.close();
raf = null;
Expand Down Expand Up @@ -353,7 +349,7 @@ private void saveHistory() throws IOException {
}
}
currFileChannel.force(true);
closeFile(currRaf, currFileChannel);
closeFile(currRaf);
Files.move(currDataFile.toPath(), new File(hisFullFileName).toPath(),
StandardCopyOption.REPLACE_EXISTING);
} catch (IOException exx) {
Expand Down

0 comments on commit 72d238d

Please sign in to comment.