Index: Connection.java =================================================================== --- Connection.java (revision 60239) +++ Connection.java (working copy) @@ -1282,14 +1282,20 @@ */ class PingTask implements Runnable { - /** - * Main processing method for the PingTask object - */ public void run() { + // Don't bother if we are closing + if (closing.get()) + return; + try { - pingTaskSemaphore.acquire(); + // If we can't aquire the semaphore then it + // almost certainly means the close has got it + // Try for 10 seconds to make sure the problem + // is not just a long garbage collection that has suspended threads + if (pingTaskSemaphore.attempt(1000 * 10) == false) + return; } catch (InterruptedException e) {