HDFS-15882. Fix incorrectly initializing RandomAccessFile based on configuration options (#2751). Contributed by Xie Lei.

Reviewed-by: He Xiaoqiao <hexiaoqiao@apache.org>
This commit is contained in:
lamberken 2021-03-13 14:22:11 +08:00 committed by GitHub
parent 7cf5969f0b
commit 6921ec8b40
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -84,9 +84,9 @@ public EditLogFileOutputStream(Configuration conf, File name, int size)
doubleBuf = new EditsDoubleBuffer(size); doubleBuf = new EditsDoubleBuffer(size);
RandomAccessFile rp; RandomAccessFile rp;
if (shouldSyncWritesAndSkipFsync) { if (shouldSyncWritesAndSkipFsync) {
rp = new RandomAccessFile(name, "rws");
} else {
rp = new RandomAccessFile(name, "rw"); rp = new RandomAccessFile(name, "rw");
} else {
rp = new RandomAccessFile(name, "rws");
} }
fp = new FileOutputStream(rp.getFD()); // open for append fp = new FileOutputStream(rp.getFD()); // open for append
fc = rp.getChannel(); fc = rp.getChannel();