private void queueReceiveAndReadTimeout(final Request request) throws TTransportException
{
if (this.receiveTimeout != null) {
long receiveTimeoutMs = this.receiveTimeout.toMillis();
if (receiveTimeoutMs > 0) {
TimerTask receiveTimeoutTask = new IoThreadBoundTimerTask(this, new TimerTask() {
@Override
public void run(Timeout timeout) {
onReceiveTimeoutFired(request);
}
});
Timeout timeout;
try {
timeout = timer.newTimeout(receiveTimeoutTask, receiveTimeoutMs, TimeUnit.MILLISECONDS);
}
catch (IllegalStateException e) {
throw new TTransportException("Unable to schedule request timeout");
}
request.setReceiveTimeout(timeout);
}
}
if (this.readTimeout != null) {
long readTimeoutNanos = this.readTimeout.roundTo(TimeUnit.NANOSECONDS);
if (readTimeoutNanos > 0) {
TimerTask readTimeoutTask = new IoThreadBoundTimerTask(this, new ReadTimeoutTask(readTimeoutNanos, request));
Timeout timeout;
try {
timeout = timer.newTimeout(readTimeoutTask, readTimeoutNanos, TimeUnit.NANOSECONDS);
}