summaryrefslogtreecommitdiff
path: root/lib/java/src/main/java/org/apache/thrift/TNonblockingMultiFetchClient.java
diff options
context:
space:
mode:
Diffstat (limited to 'lib/java/src/main/java/org/apache/thrift/TNonblockingMultiFetchClient.java')
-rw-r--r--lib/java/src/main/java/org/apache/thrift/TNonblockingMultiFetchClient.java16
1 files changed, 7 insertions, 9 deletions
diff --git a/lib/java/src/main/java/org/apache/thrift/TNonblockingMultiFetchClient.java b/lib/java/src/main/java/org/apache/thrift/TNonblockingMultiFetchClient.java
index ffe4fa701..26ea6d096 100644
--- a/lib/java/src/main/java/org/apache/thrift/TNonblockingMultiFetchClient.java
+++ b/lib/java/src/main/java/org/apache/thrift/TNonblockingMultiFetchClient.java
@@ -69,20 +69,20 @@ public class TNonblockingMultiFetchClient {
// if the size of the response msg exceeds this limit (in byte), we will
// not read the msg
- private int maxRecvBufBytesPerServer;
+ private final int maxRecvBufBytesPerServer;
// time limit for fetching data from all servers (in second)
- private int fetchTimeoutSeconds;
+ private final int fetchTimeoutSeconds;
// store request that will be sent to servers
- private ByteBuffer requestBuf;
+ private final ByteBuffer requestBuf;
private ByteBuffer requestBufDuplication;
// a list of remote servers
- private List<InetSocketAddress> servers;
+ private final List<InetSocketAddress> servers;
// store fetch results
- private TNonblockingMultiFetchStats stats;
+ private final TNonblockingMultiFetchStats stats;
private ByteBuffer[] recvBuf;
public TNonblockingMultiFetchClient(
@@ -237,6 +237,7 @@ public class TNonblockingMultiFetchClient {
try {
s.close();
} catch (Exception ex) {
+ LOGGER.error("failed to free up socket", ex);
}
}
if (key != null) {
@@ -359,13 +360,10 @@ public class TNonblockingMultiFetchClient {
public void close() {
try {
if (selector.isOpen()) {
- Iterator<SelectionKey> it = selector.keys().iterator();
- while (it.hasNext()) {
- SelectionKey selKey = it.next();
+ for (SelectionKey selKey : selector.keys()) {
SocketChannel sChannel = (SocketChannel) selKey.channel();
sChannel.close();
}
-
selector.close();
}
} catch (IOException e) {