HDFS-12606. When using native decoder, DFSStripedStream.close crashes JVM after being called multiple times. (Lei (Eddy) Xu)
This commit is contained in:
parent
6d6ca4c923
commit
46644319e1
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue