HDFS-13039. StripedBlockReader.createBlockReader leaks socket on IOException. (Lei (Eddy) Xu)
This commit is contained in:
parent
c191538ed1
commit
2ed9d61aad
|
@ -105,6 +105,7 @@ class StripedBlockReader {
|
||||||
if (offsetInBlock >= block.getNumBytes()) {
|
if (offsetInBlock >= block.getNumBytes()) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
Peer peer = null;
|
||||||
try {
|
try {
|
||||||
InetSocketAddress dnAddr =
|
InetSocketAddress dnAddr =
|
||||||
stripedReader.getSocketAddress4Transfer(source);
|
stripedReader.getSocketAddress4Transfer(source);
|
||||||
|
@ -120,7 +121,7 @@ class StripedBlockReader {
|
||||||
*
|
*
|
||||||
* TODO: add proper tracer
|
* TODO: add proper tracer
|
||||||
*/
|
*/
|
||||||
Peer peer = newConnectedPeer(block, dnAddr, blockToken, source);
|
peer = newConnectedPeer(block, dnAddr, blockToken, source);
|
||||||
if (peer.isLocal()) {
|
if (peer.isLocal()) {
|
||||||
this.isLocal = true;
|
this.isLocal = true;
|
||||||
}
|
}
|
||||||
|
@ -131,6 +132,7 @@ class StripedBlockReader {
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
LOG.info("Exception while creating remote block reader, datanode {}",
|
LOG.info("Exception while creating remote block reader, datanode {}",
|
||||||
source, e);
|
source, e);
|
||||||
|
IOUtils.closeStream(peer);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue