2) We found a possible race condition in TCPTransportClient.java: stop() -
where a connection may be in the process of being connected (pending) when we
try to close it, this results in the connection never being closed. Suggested
fix is to add code to wait a maximum of 2 seconds for a pending connection
before closing a connection: TCPTransportClient.java: stop()
stop = true;
+ logger.debug("Waiting for any pending connections to connect (wait for a
maximum of 2 second");
+ int count = 20;
+ socketChannel.finishConnect();
+ while (socketChannel != null && socketChannel.isConnectionPending() &&
count > 0) {
+ try{
+ socketChannel.finishConnect();
+ Thread.sleep(100);
+ }
+ catch(IOException e){
+ logger.error("IO Error", e);
+ }
+ catch (InterruptedException ex) {
+ logger.error("InterruptedException Error", ex);
+ }
+ count--;
+ }
+
if (socketChannel != null && socketChannel.isOpen()) {
Original issue reported on code.google.com by richgood...@gmail.com on 23 Oct 2013 at 8:19
Original issue reported on code.google.com by
richgood...@gmail.com
on 23 Oct 2013 at 8:19