Program: 156
Project: 156
Buggy source:
private <T>Future<T> doConnect(final Request request,final AsyncHandler<T> asyncHandler,NettyResponseFuture<T> f) 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=lookupInCache(uri);
  if (channel != null && channel.isOpen()) {
    if (channel.isConnected()) {
      ChannelBuffer b=null;
      if (f != null && f.getRequest().getStreamData() != 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 (!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) 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=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 (!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();
}