HDFS-12606. When using native decoder, DFSStripedStream.close crashes JVM after being called multiple times. (Lei (Eddy) Xu)

This commit is contained in:
Lei Xu 2017-10-09 10:08:30 -07:00
parent 6d6ca4c923
commit 46644319e1
2 changed files with 18 additions and 2 deletions

View File

@ -68,7 +68,7 @@ public class DFSStripedInputStream extends DFSInputStream {
private ByteBuffer curStripeBuf;
private ByteBuffer parityBuf;
private final ErasureCodingPolicy ecPolicy;
private final RawErasureDecoder decoder;
private RawErasureDecoder decoder;
/**
* Indicate the start/end offset of the current buffered stripe in the
@ -188,7 +188,10 @@ public class DFSStripedInputStream extends DFSInputStream {
BUFFER_POOL.putBuffer(parityBuf);
parityBuf = null;
}
decoder.release();
if (decoder != null) {
decoder.release();
decoder = null;
}
}
}

View File

@ -491,4 +491,17 @@ public class TestDFSStripedInputStream {
assertEquals(readSize, done);
assertArrayEquals(expected, readBuffer);
}
@Test
public void testIdempotentClose() throws Exception {
final int numBlocks = 2;
DFSTestUtil.createStripedFile(cluster, filePath, null, numBlocks,
stripesPerBlock, false, ecPolicy);
try (DFSInputStream in = fs.getClient().open(filePath.toString())) {
assertTrue(in instanceof DFSStripedInputStream);
// Close twice
in.close();
}
}
}