Skip to content

Commit

Permalink
Fix potential NPE when write FileTimeIndexCache (apache#13583)
Browse files Browse the repository at this point in the history
* Ignore the acceptable NPE then write FileTimeIndexCache

* add channal != null
  • Loading branch information
HTHou authored Sep 24, 2024
1 parent cb4befc commit 24d1191
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,11 @@ public void write(ByteBuffer logBuffer) throws IOException {
// For UT env, logFile may not be created
return;
}
channel.write(logBuffer);
if (this.forceEachWrite) {
channel.force(true);
if (channel != null && channel.isOpen()) {
channel.write(logBuffer);
if (this.forceEachWrite) {
channel.force(true);
}
}
} catch (ClosedChannelException ignored) {
logger.warn("someone interrupt current thread, so no need to do write for io safety");
Expand Down

0 comments on commit 24d1191

Please sign in to comment.