|
@@ -2926,6 +2926,7 @@ public class DFSClient implements FSConstants, java.io.Closeable {
|
|
|
// persist blocks on namenode on next flush
|
|
|
persistBlocks = true;
|
|
|
|
|
|
+ boolean result = false;
|
|
|
try {
|
|
|
LOG.debug("Connecting to " + nodes[0].getName());
|
|
|
InetSocketAddress target = NetUtils.createSocketAddr(nodes[0].getName());
|
|
@@ -2968,7 +2969,7 @@ public class DFSClient implements FSConstants, java.io.Closeable {
|
|
|
}
|
|
|
|
|
|
blockStream = out;
|
|
|
- return true; // success
|
|
|
+ result = true; // success
|
|
|
|
|
|
} catch (IOException ie) {
|
|
|
|
|
@@ -2986,8 +2987,14 @@ public class DFSClient implements FSConstants, java.io.Closeable {
|
|
|
hasError = true;
|
|
|
setLastException(ie);
|
|
|
blockReplyStream = null;
|
|
|
- return false; // error
|
|
|
+ result = false;
|
|
|
+ } finally {
|
|
|
+ if (!result) {
|
|
|
+ IOUtils.closeSocket(s);
|
|
|
+ s = null;
|
|
|
+ }
|
|
|
}
|
|
|
+ return result;
|
|
|
}
|
|
|
|
|
|
private LocatedBlock locateFollowingBlock(long start,
|