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

Signed-off-by: Duo Zhang <zhangduo@apache.org>
This commit is contained in:
Xiaolin Ha 2022-06-02 23:52:14 +08:00 committed by GitHub
parent ac8b51718f
commit 80f410ec3f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 5 deletions

View File

@ -199,7 +199,7 @@ public abstract class AbstractProtobufLogWriter {
}
} catch (Exception e) {
LOG.warn("Init output failed, path={}", path, e);
closeOutput();
closeOutputIfNecessary();
throw e;
}
}
@ -269,9 +269,10 @@ public abstract class AbstractProtobufLogWriter {
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

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

View File

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