Runnable task = new Runnable() {
@Override
public void run() {
Socket client = null;
Encoder encoder = null;
Decoder decoder = null;
try {
client = new Socket();
configure(client);
int timeoutInMillis = (int)unit.toMillis(timeout);
if (timeoutInMillis < 0) {
timeoutInMillis = DEFAULT_TIMEOUT;
}
SocketAddress addr = request.getAddress();
SocketAddress endpoint
= NetworkUtils.getResolved(addr);
client.connect(endpoint, timeoutInMillis);
encoder = createEncoder(client);
encoder.write(request);
encoder.flush();
Idle idle = new Idle();
decoder = createDecoder(client, idle);
ResponseMessage response = (ResponseMessage)decoder.read();
boolean hasContent = handleContent(response);
boolean success = handleResponse(response);
if (success && hasContent) {