Program: 135
Project: 135
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.getUsePreemptiveAuth() && realm.getScheme() == Realm.AuthScheme.NTLM) {
    if (log.isDebugEnabled()) {
      log.debug("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);
    }
  }
  ChannelBuffer bufferedBytes=null;
  if (f != null && f.getRequest().getFile() == null && !f.getNettyRequest().getMethod().getName().equals(HttpMethod.CONNECT.getName())) {
    bufferedBytes=f.getNettyRequest().getContent();
  }
  if (channel != null && channel.isOpen() && channel.isConnected()) {
    HttpRequest nettyRequest=buildRequest(config,request,uri,false,bufferedBytes);
    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_Node_Str",channel);
    }
    channel.getPipeline().getContext(NettyAsyncHttpProvider.class).setAttachment(f);
    writeRequest(channel,config,f,nettyRequest);
    return f;
  }
  if (log.isDebugEnabled()) {
    log.debug("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,bufferedBytes).build();
  ProxyServer proxyServer=request.getProxyServer() != null ? request.getProxyServer() : config.getProxyServer();
  boolean useSSl=uri.getScheme().compareToIgnoreCase(HTTPS) == 0 && proxyServer == null;
  if (useSSl) {
    constructSSLPipeline(c);
  }
  if (config.getMaxTotalConnections() != -1) {
    maxConnections.incrementAndGet();
  }
  ChannelFuture channelFuture;
  ClientBootstrap bootstrap=useSSl ? secureBootstrap : plainBootstrap;
  bootstrap.setOption("String_Node_Str",config.getConnectionTimeoutInMs());
  if (System.getProperty("String_Node_Str").toLowerCase().indexOf("String_Node_Str") == -1) {
    bootstrap.setOption("String_Node_Str",true);
  }
  try {
    if (proxyServer == null) {
      channelFuture=bootstrap.connect(new InetSocketAddress(uri.getHost(),AsyncHttpProviderUtils.getPort(uri)));
    }
 else {
      channelFuture=bootstrap.connect(new InetSocketAddress(proxyServer.getHost(),proxyServer.getPort()));
    }
  }
 catch (  Throwable t) {
    log.error("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();
}

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.getUsePreemptiveAuth() && realm.getScheme() == Realm.AuthScheme.NTLM) {
    if (log.isDebugEnabled()) {
      log.debug("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);
    }
  }
  ChannelBuffer bufferedBytes=null;
  if (f != null && f.getRequest().getFile() == null && !f.getNettyRequest().getMethod().getName().equals(HttpMethod.CONNECT.getName())) {
    bufferedBytes=f.getNettyRequest().getContent();
  }
  if (channel != null && channel.isOpen() && channel.isConnected()) {
    HttpRequest nettyRequest=buildRequest(config,request,uri,false,bufferedBytes);
    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_Node_Str",channel);
    }
    channel.getPipeline().getContext(NettyAsyncHttpProvider.class).setAttachment(f);
    writeRequest(channel,config,f,nettyRequest);
    return f;
  }
  if (log.isDebugEnabled()) {
    log.debug("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,bufferedBytes).build(uri);
  ProxyServer proxyServer=request.getProxyServer() != null ? request.getProxyServer() : config.getProxyServer();
  boolean useSSl=uri.getScheme().compareToIgnoreCase(HTTPS) == 0 && proxyServer == null;
  if (useSSl) {
    constructSSLPipeline(c);
  }
  if (config.getMaxTotalConnections() != -1) {
    maxConnections.incrementAndGet();
  }
  ChannelFuture channelFuture;
  ClientBootstrap bootstrap=useSSl ? secureBootstrap : plainBootstrap;
  bootstrap.setOption("String_Node_Str",config.getConnectionTimeoutInMs());
  if (System.getProperty("String_Node_Str").toLowerCase().indexOf("String_Node_Str") == -1) {
    bootstrap.setOption("String_Node_Str",true);
  }
  try {
    if (proxyServer == null) {
      channelFuture=bootstrap.connect(new InetSocketAddress(uri.getHost(),AsyncHttpProviderUtils.getPort(uri)));
    }
 else {
      channelFuture=bootstrap.connect(new InetSocketAddress(proxyServer.getHost(),proxyServer.getPort()));
    }
  }
 catch (  Throwable t) {
    log.error("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();
}