} else if (key.isWritable()) {
// deal with writes
handleWrite(key);
+ } else {
+ LOGGER.log(Level.WARNING, "Unexpected state in select! " + key.interestOps());
}
}
} catch (IOException e) {
*/
private void handleAccept() throws IOException {
SelectionKey clientKey = null;
+ TNonblockingTransport client = null;
try {
// accept the connection
- TNonblockingTransport client = (TNonblockingTransport)serverTransport.accept();
+ client = (TNonblockingTransport)serverTransport.accept();
clientKey = client.registerSelector(selector, SelectionKey.OP_READ);
// add this key to the map
clientKey.attach(frameBuffer);
} catch (TTransportException tte) {
// something went wrong accepting.
- cleanupSelectionkey(clientKey);
LOGGER.log(Level.WARNING, "Exception trying to accept!", tte);
tte.printStackTrace();
+ if (clientKey != null) cleanupSelectionkey(clientKey);
+ if (client != null) client.close();
}
}