THRIFT-2108 java: Fix TAsyncClientManager timeout race
Patch: Vadim Spivak
diff --git a/lib/java/src/org/apache/thrift/async/TAsyncMethodCall.java b/lib/java/src/org/apache/thrift/async/TAsyncMethodCall.java
index fcd50ea..5c679b6 100644
--- a/lib/java/src/org/apache/thrift/async/TAsyncMethodCall.java
+++ b/lib/java/src/org/apache/thrift/async/TAsyncMethodCall.java
@@ -65,7 +65,8 @@
   private final AsyncMethodCallback<T> callback;
   private final boolean isOneway;
   private long sequenceId;
-  
+  private final long timeout;
+
   private ByteBuffer sizeBuffer;
   private final byte[] sizeBufferArray = new byte[4];
   private ByteBuffer frameBuffer;
@@ -79,6 +80,7 @@
     this.client = client;
     this.isOneway = isOneway;
     this.sequenceId = TAsyncMethodCall.sequenceIdCounter.getAndIncrement();
+    this.timeout = client.getTimeout();
   }
 
   protected State getState() {
@@ -102,11 +104,11 @@
   }
   
   public boolean hasTimeout() {
-    return client.hasTimeout();
+    return timeout > 0;
   }
   
   public long getTimeoutTimestamp() {
-    return client.getTimeout() + startTime;
+    return timeout + startTime;
   }
 
   protected abstract void write_args(TProtocol protocol) throws TException;