HBASE-26680 Close and do not write trailer for the broken WAL writer(addendum) (#4405)

Signed-off-by: Duo Zhang <zhangduo@apache.org>
(cherry picked from commit 80f410ec3f)
This commit is contained in:
Xiaolin Ha 2022-06-02 23:52:14 +08:00 committed by Duo Zhang
parent 3ce6e1afe7
commit df9739979e
3 changed files with 6 additions and 5 deletions

View File

@ -173,7 +173,7 @@ public abstract class AbstractProtobufLogWriter {
}
} catch (Exception e) {
LOG.warn("Init output failed, path={}", path, e);
closeOutput();
closeOutputIfNecessary();
throw e;
}
}
@ -242,9 +242,10 @@ public abstract class AbstractProtobufLogWriter {
short replication, long blockSize) throws IOException, StreamLacksCapabilityException;
/**
* simply close the output, do not need to write trailer like the Writer.close
* It is straight forward to close the output, do not need to write trailer like the Writer.close
*/
protected abstract void closeOutput();
protected void closeOutputIfNecessary() {
}
/**
* return the file length after written.

View File

@ -193,7 +193,7 @@ public class AsyncProtobufLogWriter extends AbstractProtobufLogWriter
}
@Override
protected void closeOutput() {
protected void closeOutputIfNecessary() {
if (this.output != null) {
try {
this.output.close();

View File

@ -116,7 +116,7 @@ public class ProtobufLogWriter extends AbstractProtobufLogWriter implements FSHL
}
@Override
protected void closeOutput() {
protected void closeOutputIfNecessary() {
if (this.output != null) {
try {
this.output.close();