Program: 146
Project: 146
Buggy source:
private <T>Future<T> doConnect(final Request request,final AsyncHandler<T> asyncHandler,NettyResponseFuture<T> f,boolean useCache) throws IOException {
  if (isClose.get()) {
    throw new IOException("String_Node_Str");
  }
  Realm realm=request.getRealm() != null ? request.getRealm() : config.getRealm();
  if (realm != null && realm.getScheme() == Realm.AuthScheme.NTLM) {
    if (log.isDebugEnabled()) {
      log.debug(currentThread() + "String_Node_Str" + JDKAsyncHttpProvider.class.getName());
    }
    return ntlmProvider.execute(request,asyncHandler);
  }
  URI uri=AsyncHttpProviderUtils.createUri(request.getUrl());
  Channel channel=null;
  if (useCache) {
    if (f != null && f.channel() != null) {
      channel=f.channel();
    }
 else {
      channel=lookupInCache(uri);
    }
  }
  if (channel != null && channel.isOpen()) {
    if (channel.isConnected()) {
      ChannelBuffer b=null;
      if (f != null && f.getRequest().getFile() == null) {
        b=f.getNettyRequest().getContent();
      }
      HttpRequest nettyRequest=buildRequest(config,request,uri,false,b);
      if (f == null) {
        f=new NettyResponseFuture<T>(uri,request,asyncHandler,nettyRequest,requestTimeout(config,request.getPerRequestConfig()),this);
      }
 else {
        f.setNettyRequest(nettyRequest);
      }
      f.setState(NettyResponseFuture.STATE.POOLED);
      if (log.isDebugEnabled()) {
        log.debug(String.format(currentThread() + "String_Node_Str",request.toString()));
      }
      channel.getPipeline().getContext(NettyAsyncHttpProvider.class).setAttachment(f);
      writeRequest(channel,config,f,nettyRequest);
      return f;
    }
  }
  if (log.isDebugEnabled()) {
    log.debug(String.format(currentThread() + "String_Node_Str",request.toString()));
  }
  if (!connectionsPool.canCacheConnection() || (config.getMaxTotalConnections() > -1 && (maxConnections.get() + 1) > config.getMaxTotalConnections())) {
    throw new IOException(String.format("String_Node_Str",config.getMaxTotalConnections()));
  }
  NettyConnectListener<T> c=new NettyConnectListener.Builder<T>(config,request,asyncHandler,f,this).build();
  ProxyServer proxyServer=request.getProxyServer() != null ? request.getProxyServer() : config.getProxyServer();
  boolean useSSl=uri.getScheme().compareToIgnoreCase("String_Node_Str") == 0 && (proxyServer == null || !proxyServer.getProtocolAsString().equals("String_Node_Str"));
  if (useSSl) {
    constructSSLPipeline(c);
  }
  if (config.getMaxTotalConnections() != -1) {
    maxConnections.incrementAndGet();
  }
  ChannelFuture channelFuture;
  ClientBootstrap bootstrap=useSSl ? secureBootstrap : plainBootstrap;
  try {
    if (proxyServer == null) {
      channelFuture=bootstrap.connect(new InetSocketAddress(uri.getHost(),AsyncHttpProviderUtils.getPort(uri)));
    }
 else {
      channelFuture=bootstrap.connect(new InetSocketAddress(proxyServer.getHost(),proxyServer.getPort()));
    }
    bootstrap.setOption("String_Node_Str",config.getConnectionTimeoutInMs());
  }
 catch (  Throwable t) {
    log.error(String.format(currentThread() + "String_Node_Str"),t);
    abort(c.future(),t.getCause());
    return c.future();
  }
  boolean directInvokation=true;
  if (IoWorkerRunnable.IN_IO_THREAD.get() && DefaultChannelFuture.isUseDeadLockChecker()) {
    directInvokation=false;
  }
  if (directInvokation && !executeConnectAsync && request.getFile() == null) {
    channelFuture.awaitUninterruptibly();
    try {
      c.operationComplete(channelFuture);
    }
 catch (    Exception e) {
      IOException ioe=new IOException(e.getMessage());
      ioe.initCause(e);
      throw ioe;
    }
  }
 else {
    channelFuture.addListener(c);
  }
  openChannels.add(channelFuture.getChannel());
  return c.future();
}

Fixed version (ground truth):
private <T>Future<T> doConnect(final Request request,final AsyncHandler<T> asyncHandler,NettyResponseFuture<T> f,boolean useCache) throws IOException {
  if (isClose.get()) {
    throw new IOException("String_Node_Str");
  }
  Realm realm=request.getRealm() != null ? request.getRealm() : config.getRealm();
  if (realm != null && realm.getScheme() == Realm.AuthScheme.NTLM) {
    if (log.isDebugEnabled()) {
      log.debug(currentThread() + "String_Node_Str" + JDKAsyncHttpProvider.class.getName());
    }
    return ntlmProvider.execute(request,asyncHandler);
  }
  URI uri=AsyncHttpProviderUtils.createUri(request.getUrl());
  Channel channel=null;
  if (useCache) {
    if (f != null && f.channel() != null) {
      channel=f.channel();
    }
 else {
      channel=lookupInCache(uri);
    }
  }
  if (channel != null && channel.isOpen()) {
    if (channel.isConnected()) {
      ChannelBuffer b=null;
      if (f != null && f.getRequest().getFile() == null) {
        b=f.getNettyRequest().getContent();
      }
      HttpRequest nettyRequest=buildRequest(config,request,uri,false,b);
      if (f == null) {
        f=new NettyResponseFuture<T>(uri,request,asyncHandler,nettyRequest,requestTimeout(config,request.getPerRequestConfig()),this);
      }
 else {
        f.setNettyRequest(nettyRequest);
      }
      f.setState(NettyResponseFuture.STATE.POOLED);
      if (log.isDebugEnabled()) {
        log.debug(String.format(currentThread() + "String_Node_Str",request.toString()));
      }
      channel.getPipeline().getContext(NettyAsyncHttpProvider.class).setAttachment(f);
      writeRequest(channel,config,f,nettyRequest);
      return f;
    }
  }
  if (log.isDebugEnabled()) {
    log.debug(String.format(currentThread() + "String_Node_Str",request.toString()));
  }
  if (!connectionsPool.canCacheConnection() || (config.getMaxTotalConnections() > -1 && (maxConnections.get() + 1) > config.getMaxTotalConnections())) {
    throw new IOException(String.format("String_Node_Str",config.getMaxTotalConnections()));
  }
  NettyConnectListener<T> c=new NettyConnectListener.Builder<T>(config,request,asyncHandler,f,this).build();
  ProxyServer proxyServer=request.getProxyServer() != null ? request.getProxyServer() : config.getProxyServer();
  boolean useSSl=uri.getScheme().compareToIgnoreCase("String_Node_Str") == 0 && (proxyServer == null || !proxyServer.getProtocolAsString().equals("String_Node_Str"));
  if (useSSl) {
    constructSSLPipeline(c);
  }
  if (config.getMaxTotalConnections() != -1) {
    maxConnections.incrementAndGet();
  }
  ChannelFuture channelFuture;
  ClientBootstrap bootstrap=useSSl ? secureBootstrap : plainBootstrap;
  try {
    if (proxyServer == null) {
      channelFuture=bootstrap.connect(new InetSocketAddress(uri.getHost(),AsyncHttpProviderUtils.getPort(uri)));
    }
 else {
      channelFuture=bootstrap.connect(new InetSocketAddress(proxyServer.getHost(),proxyServer.getPort()));
    }
    bootstrap.setOption("String_Node_Str",config.getConnectionTimeoutInMs());
  }
 catch (  Throwable t) {
    log.error(String.format(currentThread() + "String_Node_Str"),t);
    abort(c.future(),t.getCause());
    return c.future();
  }
  boolean directInvokation=true;
  if (IN_IO_THREAD.get() && DefaultChannelFuture.isUseDeadLockChecker()) {
    directInvokation=false;
  }
  if (directInvokation && !executeConnectAsync && request.getFile() == null) {
    channelFuture.awaitUninterruptibly();
    try {
      c.operationComplete(channelFuture);
    }
 catch (    Exception e) {
      IOException ioe=new IOException(e.getMessage());
      ioe.initCause(e);
      throw ioe;
    }
  }
 else {
    channelFuture.addListener(c);
  }
  openChannels.add(channelFuture.getChannel());
  return c.future();
}