Program: 148
Project: 148
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");
  }
  if (request.getRealm() != null && request.getRealm().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);
      try {
        executeRequest(channel,config,f,nettyRequest);
        return f;
      }
 catch (      ConnectException ex) {
        if (log.isDebugEnabled()) {
          log.debug(currentThread() + ex.getMessage());
          log.debug(ex);
        }
      }
    }
  }
  if (!connectionsPool.canCacheConnection() || (config.getMaxTotalConnections() > -1 && (maxConnections.get() + 1) > config.getMaxTotalConnections())) {
    throw new IOException(String.format("String_Node_Str",config.getMaxTotalConnections()));
  }
  ConnectListener<T> c=new ConnectListener.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();
  }
  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");
  }
  if (request.getRealm() != null && request.getRealm().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);
      try {
        executeRequest(channel,config,f,nettyRequest);
        return f;
      }
 catch (      ConnectException ex) {
        if (log.isDebugEnabled()) {
          log.debug(currentThread() + ex.getMessage());
          log.debug(ex);
        }
      }
    }
  }
  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()));
  }
  ConnectListener<T> c=new ConnectListener.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();
  }
  channelFuture.addListener(c);
  channelFuture.getChannel().getPipeline().getContext(NettyAsyncHttpProvider.class).setAttachment(c.future());
  openChannels.add(channelFuture.getChannel());
  return c.future();
}