Source:
<code>public void connect() throws ClientConnectionException { if (isOpen()) { return; } try (LockWrapper wrapper = new LockWrapper(this.lock)) { if (isOpen() && isInInit()) { <START> if (getPostConnectCallback().await(policy.getRetryTimeOut(), policy.getTimeUnit())) { <END> closeChannel(); throw new ClientConnectionException("Connection timeout"); } } if (isOpen()) { return; } final FutureTask<SocketChannel> task = scheduleTask(new Retryable<SocketChannel>( new Callable<SocketChannel>() { @Override public SocketChannel call() throws IOException { InetAddress address = InetAddress.getByName(hostname); log.info("Connecting to " + address); final InetSocketAddress addr = new InetSocketAddress(address, port); final SocketChannel socketChannel = SocketChannel.open(); socketChannel.configureBlocking(false); socketChannel.connect(addr); return socketChannel; } }, this.policy)); this.channel = task.get(); while (!this.channel.finishConnect()) { final long timeout = getTimeout(policy.getRetryTimeOut(), policy.getTimeUnit()); final FutureTask<SocketChannel> connectTask = scheduleTask(new Retryable<SocketChannel>( new Callable<SocketChannel>() { @Override public SocketChannel call() throws ConnectException { if (System.currentTimeMillis() >= timeout) { throw new ConnectException("Connection timeout"); } return null; } }, this.policy)); connectTask.get(); } updateLastIncomingHeartbeat(); updateLastOutgoingHeartbeat(); if (!isOpen()) { throw new ClientConnectionException("Connection failed"); } postConnect(getPostConnectCallback()); } catch (InterruptedException | ExecutionException e) { logException(log, "Exception during connection", e); final String message = "Connection issue " + e.getMessage(); final Callable<Void> disconnectCallable = new Callable<Void>() { @Override public Void call() { disconnect(message); return null; } }; scheduleTask(disconnectCallable); throw new ClientConnectionException(e); } catch (IOException e) { closeChannel(); throw new ClientConnectionException("Connection failed"); } }</code><technical_language>condition</technical_language>

Target:
public void connect() throws ClientConnectionException { if (isOpen()) { return; } try (LockWrapper wrapper = new LockWrapper(this.lock)) { if (isOpen() && isInInit()) { if (!getPostConnectCallback().await(policy.getRetryTimeOut(), policy.getTimeUnit())) { closeChannel(); throw new ClientConnectionException("Connection timeout"); } } if (isOpen()) { return; } final FutureTask<SocketChannel> task = scheduleTask(new Retryable<SocketChannel>( new Callable<SocketChannel>() { @Override public SocketChannel call() throws IOException { InetAddress address = InetAddress.getByName(hostname); log.info("Connecting to " + address); final InetSocketAddress addr = new InetSocketAddress(address, port); final SocketChannel socketChannel = SocketChannel.open(); socketChannel.configureBlocking(false); socketChannel.connect(addr); return socketChannel; } }, this.policy)); this.channel = task.get(); while (!this.channel.finishConnect()) { final long timeout = getTimeout(policy.getRetryTimeOut(), policy.getTimeUnit()); final FutureTask<SocketChannel> connectTask = scheduleTask(new Retryable<SocketChannel>( new Callable<SocketChannel>() { @Override public SocketChannel call() throws ConnectException { if (System.currentTimeMillis() >= timeout) { throw new ConnectException("Connection timeout"); } return null; } }, this.policy)); connectTask.get(); } updateLastIncomingHeartbeat(); updateLastOutgoingHeartbeat(); if (!isOpen()) { throw new ClientConnectionException("Connection failed"); } postConnect(getPostConnectCallback()); } catch (InterruptedException | ExecutionException e) { logException(log, "Exception during connection", e); final String message = "Connection issue " + e.getMessage(); final Callable<Void> disconnectCallable = new Callable<Void>() { @Override public Void call() { disconnect(message); return null; } }; scheduleTask(disconnectCallable); throw new ClientConnectionException(e); } catch (IOException e) { closeChannel(); throw new ClientConnectionException("Connection failed"); } }