Skip to content

Commit

Permalink
reverted try-with-resources for FileChannel
Browse files Browse the repository at this point in the history
  • Loading branch information
dk2k committed Jul 1, 2024
1 parent 3030303 commit 69cb849
Showing 1 changed file with 13 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -180,24 +180,23 @@ private synchronized BufferedLogChannel allocateNewLog(File dirForNextEntryLog,
} while (testLogFile == null);

File newLogFile = new File(dirForNextEntryLog, logFileName);
try (FileChannel channel = new RandomAccessFile(newLogFile, "rw").getChannel()) {
FileChannel channel = new RandomAccessFile(newLogFile, "rw").getChannel();

BufferedLogChannel logChannel = new BufferedLogChannel(byteBufAllocator, channel, conf.getWriteBufferBytes(),
conf.getReadBufferBytes(), preallocatedLogId, newLogFile, conf.getFlushIntervalInBytes());
logfileHeader.readerIndex(0);
logChannel.write(logfileHeader);
BufferedLogChannel logChannel = new BufferedLogChannel(byteBufAllocator, channel, conf.getWriteBufferBytes(),
conf.getReadBufferBytes(), preallocatedLogId, newLogFile, conf.getFlushIntervalInBytes());
logfileHeader.readerIndex(0);
logChannel.write(logfileHeader);

for (File f : ledgersDirs) {
setLastLogId(f, preallocatedLogId);
}

if (suffix.equals(DefaultEntryLogger.LOG_FILE_SUFFIX)) {
recentlyCreatedEntryLogsStatus.createdEntryLog(preallocatedLogId);
}
for (File f : ledgersDirs) {
setLastLogId(f, preallocatedLogId);
}

log.info("Created new entry log file {} for logId {}.", newLogFile, preallocatedLogId);
return logChannel;
if (suffix.equals(DefaultEntryLogger.LOG_FILE_SUFFIX)) {
recentlyCreatedEntryLogsStatus.createdEntryLog(preallocatedLogId);
}

log.info("Created new entry log file {} for logId {}.", newLogFile, preallocatedLogId);
return logChannel;
}


Expand Down

0 comments on commit 69cb849

Please sign in to comment.