HDFS-15779. EC: fix NPE caused by StripedWriter.clearBuffers during reconstruct block. Contributed by Hongbing Wang
This commit is contained in:
parent
182623d2bc
commit
15a1f7adfc
@ -296,7 +296,8 @@ boolean hasValidTargets() {
|
|||||||
*/
|
*/
|
||||||
void clearBuffers() {
|
void clearBuffers() {
|
||||||
for (StripedBlockWriter writer : writers) {
|
for (StripedBlockWriter writer : writers) {
|
||||||
ByteBuffer targetBuffer = writer.getTargetBuffer();
|
ByteBuffer targetBuffer =
|
||||||
|
writer != null ? writer.getTargetBuffer() : null;
|
||||||
if (targetBuffer != null) {
|
if (targetBuffer != null) {
|
||||||
targetBuffer.clear();
|
targetBuffer.clear();
|
||||||
}
|
}
|
||||||
@ -305,7 +306,8 @@ void clearBuffers() {
|
|||||||
|
|
||||||
void close() {
|
void close() {
|
||||||
for (StripedBlockWriter writer : writers) {
|
for (StripedBlockWriter writer : writers) {
|
||||||
ByteBuffer targetBuffer = writer.getTargetBuffer();
|
ByteBuffer targetBuffer =
|
||||||
|
writer != null ? writer.getTargetBuffer() : null;
|
||||||
if (targetBuffer != null) {
|
if (targetBuffer != null) {
|
||||||
reconstructor.freeBuffer(targetBuffer);
|
reconstructor.freeBuffer(targetBuffer);
|
||||||
writer.freeTargetBuffer();
|
writer.freeTargetBuffer();
|
||||||
@ -313,7 +315,9 @@ void close() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < targets.length; i++) {
|
for (int i = 0; i < targets.length; i++) {
|
||||||
|
if (writers[i] != null) {
|
||||||
writers[i].close();
|
writers[i].close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user