Program: 97761
Project: 97761
Buggy source:
protected Socket connect(final RequestBuilder r,final List<Transport> transports,final long timeout,final TimeUnit tu) throws IOException {
  if (transports.size() > 0) {
    transportInUse=transports.get(0);
  }
 else {
    throw new IOException("String_Node_Str");
  }
  socketRuntime=createRuntime();
  addFunction(timeout,tu);
  if (transportInUse.name().equals(Request.TRANSPORT.WEBSOCKET)) {
    r.setUrl(request.uri().replace("String_Node_Str","String_Node_Str"));
    try {
      java.util.concurrent.Future<WebSocket> fw=options.runtime().prepareRequest(r.build()).execute((AsyncHandler<WebSocket>)transportInUse);
      fw.get(timeout,tu);
      socketRuntime=createRuntime(options,functions);
    }
 catch (    ExecutionException t) {
      Throwable e=t.getCause();
      if (TransportNotSupported.class.isAssignableFrom(e.getClass())) {
        return this;
      }
      transportInUse.close();
      closeRuntime(true);
      if (!transportInUse.errorHandled() && TimeoutException.class.isAssignableFrom(e.getClass())) {
        transportInUse.error(new IOException("String_Node_Str" + e.getMessage()));
      }
      return new VoidSocket();
    }
catch (    Throwable t) {
      transportInUse.onThrowable(t);
      return new VoidSocket();
    }
  }
 else {
    r.setUrl(request.uri().replace("String_Node_Str","String_Node_Str"));
    transportInUse.future(options.runtime().prepareRequest(r.build()).execute((AsyncHandler<String>)transportInUse));
    try {
      if (options.waitBeforeUnlocking() > 0) {
        logger.info("String_Node_Str",options.waitBeforeUnlocking());
      }
      socketRuntime.future().get(options.waitBeforeUnlocking(),TimeUnit.MILLISECONDS);
      socketRuntime.future().done();
    }
 catch (    Throwable t) {
      logger.trace("String_Node_Str",t);
    }
    socketRuntime=createRuntime();
  }
  return this;
}

Fixed version (ground truth):
protected Socket connect(final RequestBuilder r,final List<Transport> transports,final long timeout,final TimeUnit tu) throws IOException {
  if (transports.size() > 0) {
    transportInUse=transports.get(0);
  }
 else {
    throw new IOException("String_Node_Str");
  }
  DefaultFuture f=new DefaultFuture(this);
  socketRuntime=createRuntime(f,options,functions);
  transportInUse.connectedFuture(f);
  addFunction(timeout,tu);
  if (transportInUse.name().equals(Request.TRANSPORT.WEBSOCKET)) {
    r.setUrl(request.uri().replace("String_Node_Str","String_Node_Str"));
    try {
      java.util.concurrent.Future<WebSocket> fw=options.runtime().prepareRequest(r.build()).execute((AsyncHandler<WebSocket>)transportInUse);
      fw.get(timeout,tu);
    }
 catch (    ExecutionException t) {
      Throwable e=t.getCause();
      if (TransportNotSupported.class.isAssignableFrom(e.getClass())) {
        return this;
      }
      transportInUse.close();
      closeRuntime(true);
      if (!transportInUse.errorHandled() && TimeoutException.class.isAssignableFrom(e.getClass())) {
        transportInUse.error(new IOException("String_Node_Str" + e.getMessage()));
      }
      return new VoidSocket();
    }
catch (    Throwable t) {
      transportInUse.onThrowable(t);
      return new VoidSocket();
    }
  }
 else {
    r.setUrl(request.uri().replace("String_Node_Str","String_Node_Str"));
    transportInUse.future(options.runtime().prepareRequest(r.build()).execute((AsyncHandler<String>)transportInUse));
    try {
      if (options.waitBeforeUnlocking() > 0) {
        logger.info("String_Node_Str",options.waitBeforeUnlocking());
      }
      if (request.queryString().containsKey("String_Node_Str")) {
        f.get();
      }
 else {
        f.get(options.waitBeforeUnlocking(),TimeUnit.MILLISECONDS);
      }
    }
 catch (    Throwable t) {
      logger.trace("String_Node_Str",t);
    }
 finally {
      f.done();
    }
  }
  return this;
}