@SuppressWarnings("unchecked") void check() { watchDogRuns++; long current = System.currentTimeMillis(); ArrayList<WeakReference<TimeoutMgmHandle>> connectionsCopy = null; synchronized (handles) { connectionsCopy = (ArrayList<WeakReference<TimeoutMgmHandle>>) handles.clone(); } for (WeakReference<TimeoutMgmHandle> handleRef : connectionsCopy) { TimeoutMgmHandle handle = handleRef.get(); if (handle == null) { remove(handleRef); } else { NonBlockingConnection con = handle.getConnection(); if (con.isOpen()) { checkTimeout(con, current); } else { remove(handleRef); } } } computeSize(); }