From 6921ec8b40fef7bbf7b2f38f438698bc0d594a46 Mon Sep 17 00:00:00 2001 From: lamberken <2217232293@qq.com> Date: Sat, 13 Mar 2021 14:22:11 +0800 Subject: [PATCH] HDFS-15882. Fix incorrectly initializing RandomAccessFile based on configuration options (#2751). Contributed by Xie Lei. Reviewed-by: He Xiaoqiao --- .../hadoop/hdfs/server/namenode/EditLogFileOutputStream.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/EditLogFileOutputStream.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/EditLogFileOutputStream.java index 4919ea44e0..493a542d1b 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/EditLogFileOutputStream.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/EditLogFileOutputStream.java @@ -84,9 +84,9 @@ public EditLogFileOutputStream(Configuration conf, File name, int size) doubleBuf = new EditsDoubleBuffer(size); RandomAccessFile rp; if (shouldSyncWritesAndSkipFsync) { - rp = new RandomAccessFile(name, "rws"); - } else { rp = new RandomAccessFile(name, "rw"); + } else { + rp = new RandomAccessFile(name, "rws"); } fp = new FileOutputStream(rp.getFD()); // open for append fc = rp.getChannel();