From ba4cbb79280c3cf1e8b4ea468d83084b9328e2c3 Mon Sep 17 00:00:00 2001 From: vintmd <61688729+vintmd@users.noreply.github.com> Date: Tue, 19 Jul 2022 16:26:13 +0800 Subject: [PATCH] dirty flush only work when open flush (#70) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: alantong(佟明达) --- .../java/org/apache/hadoop/fs/CosNFSDataOutputStream.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/apache/hadoop/fs/CosNFSDataOutputStream.java b/src/main/java/org/apache/hadoop/fs/CosNFSDataOutputStream.java index c9845b27..6ac575f7 100644 --- a/src/main/java/org/apache/hadoop/fs/CosNFSDataOutputStream.java +++ b/src/main/java/org/apache/hadoop/fs/CosNFSDataOutputStream.java @@ -178,7 +178,10 @@ public synchronized void flush() throws IOException { private void innerFlush(boolean closeStream) throws IOException { this.checkOpened(); - if (!this.dirty) { + // when close flush data to cos, each time data not upload, + // at this time if we close stream, it is not dirty but also has data need to upload + // so the dirty flag only useful when flush cos enabled. + if (!this.dirty && this.flushCOSEnabled) { LOG.debug("The stream is up-to-date, no need to refresh."); return; }