Commit b0801c31 authored by chiaming2000's avatar chiaming2000
Browse files

Java API: Fixed writing thread is blocked until timeout when closed.

This could happen when a connection was closed while a separate thread
was sending messages with the closed connection. The application was
blocked until timeout expired (default 60 seconds).    
parent 50d172ae
Loading
Loading
Loading
Loading
+5 −5
Original line number Diff line number Diff line
@@ -103,8 +103,7 @@ public class MessageHandler implements ClientMessageService, Runnable {
		this.asyncQueuedSize = this.client.getConfiguration()
				.getAsyncQueueSize();

		this.requestTimeout = this.client.getConfiguration()
				.getRequestTimeoutMillis();
		this.requestTimeout = this.client.getConfiguration().getRequestTimeoutMillis();
	}
	

@@ -300,11 +299,12 @@ public class MessageHandler implements ClientMessageService, Runnable {
                this.doWrite(message);
            }

			respond = lbq.poll(this.requestTimeout, TimeUnit.MILLISECONDS);

            if (this.isClosed) {
				throw new IOException("Connection is closed.");
			} else {
				respond = lbq.poll(this.requestTimeout, TimeUnit.MILLISECONDS);
			}
			
		} finally {
			this.ackmap.remove(seq);
		}