Merge. HDFS-5671. Fix socket leak in DFSInputStream#getBlockReader. Contributed by JamesLi

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-2@1554556 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Uma Maheswara Rao G 2013-12-31 16:26:48 +00:00
parent 5f698ffb57
commit 1df8cb9ce0
2 changed files with 16 additions and 4 deletions

View File

@ -438,6 +438,8 @@ Release 2.3.0 - UNRELEASED
HDFS-5582. hdfs getconf -excludeFile or -includeFile always failed (sathish HDFS-5582. hdfs getconf -excludeFile or -includeFile always failed (sathish
via cmccabe) via cmccabe)
HDFS-5671. Fix socket leak in DFSInputStream#getBlockReader. (JamesLi via umamahesh)
Release 2.2.0 - 2013-10-13 Release 2.2.0 - 2013-10-13
INCOMPATIBLE CHANGES INCOMPATIBLE CHANGES

View File

@ -1188,11 +1188,21 @@ implements ByteBufferReadable, CanSetDropBehind, CanSetReadahead,
} }
// Try to create a new remote peer. // Try to create a new remote peer.
Peer peer = newTcpPeer(dnAddr); Peer peer = newTcpPeer(dnAddr);
return BlockReaderFactory.newBlockReader( try {
dfsClient.getConf(), file, block, blockToken, startOffset, reader = BlockReaderFactory.newBlockReader(dfsClient.getConf(), file,
len, verifyChecksum, clientName, peer, chosenNode, block, blockToken, startOffset, len, verifyChecksum, clientName,
dsFactory, peerCache, fileInputStreamCache, false, peer, chosenNode, dsFactory, peerCache, fileInputStreamCache, false,
curCachingStrategy); curCachingStrategy);
return reader;
} catch (IOException ex) {
DFSClient.LOG.debug(
"Exception while getting block reader, closing stale " + peer, ex);
throw ex;
} finally {
if (reader == null) {
IOUtils.closeQuietly(peer);
}
}
} }