Program: 94150
Project: 94150
Buggy source:
private RawResponse doRequest(Request request){
  Charset charset=request.getCharset();
  URL url=request.getUrl();
  @Nullable RequestBody body=request.getBody();
  @Nullable URLConnectionSessionContext sessionContext=(URLConnectionSessionContext)request.getSessionContext();
  CookieJar cookieJar;
  if (sessionContext == null) {
    cookieJar=NopCookieJar.instance;
  }
 else {
    cookieJar=sessionContext.getCookieJar();
  }
  HttpURLConnection conn;
  try {
    @Nullable Proxy proxy=request.getProxy();
    if (proxy != null) {
      conn=(HttpURLConnection)url.openConnection(proxy);
    }
 else {
      conn=(HttpURLConnection)url.openConnection();
    }
  }
 catch (  IOException e) {
    throw new RequestsException(e);
  }
  conn.setUseCaches(false);
  if (conn instanceof HttpsURLConnection) {
    SSLSocketFactory ssf=null;
    if (!request.isVerify()) {
      ssf=SSLSocketFactories.getTrustAllSSLSocketFactory();
      ((HttpsURLConnection)conn).setHostnameVerifier(NopHostnameVerifier.getInstance());
    }
 else     if (!request.getCerts().isEmpty()) {
      ssf=SSLSocketFactories.getCustomSSLSocketFactory(request.getCerts());
    }
    if (ssf != null) {
      ((HttpsURLConnection)conn).setSSLSocketFactory(ssf);
    }
  }
  try {
    conn.setRequestMethod(request.getMethod());
  }
 catch (  ProtocolException e) {
    throw new RequestsException(e);
  }
  conn.setReadTimeout(request.getSocksTimeout());
  conn.setConnectTimeout(request.getConnectTimeout());
  conn.setInstanceFollowRedirects(false);
  if (body != null) {
    conn.setDoOutput(true);
    String contentType=body.getContentType();
    if (contentType != null) {
      if (body.isIncludeCharset()) {
        contentType+="String_Node_Str" + request.getCharset().name().toLowerCase();
      }
      conn.setRequestProperty(NAME_CONTENT_TYPE,contentType);
    }
  }
  if (!request.getUserAgent().isEmpty()) {
    conn.setRequestProperty(NAME_USER_AGENT,request.getUserAgent());
  }
  if (request.isCompress()) {
    conn.setRequestProperty(NAME_ACCEPT_ENCODING,"String_Node_Str");
  }
  if (request.getBasicAuth() != null) {
    conn.setRequestProperty(NAME_AUTHORIZATION,request.getBasicAuth().encode());
  }
  Collection<Cookie> sessionCookies=cookieJar.getCookies(url);
  if (!request.getCookies().isEmpty() || !sessionCookies.isEmpty()) {
    StringBuilder sb=new StringBuilder();
    for (    Map.Entry<String,?> entry : request.getCookies()) {
      sb.append(entry.getKey()).append("String_Node_Str").append(String.valueOf(entry.getValue())).append("String_Node_Str");
    }
    for (    Cookie cookie : sessionCookies) {
      sb.append(cookie.getName()).append("String_Node_Str").append(cookie.getValue()).append("String_Node_Str");
    }
    if (sb.length() > 2) {
      sb.setLength(sb.length() - 2);
      String cookieStr=sb.toString();
      conn.setRequestProperty(NAME_COOKIE,cookieStr);
    }
  }
  for (  Map.Entry<String,?> header : request.getHeaders()) {
    conn.setRequestProperty(header.getKey(),String.valueOf(header.getValue()));
  }
  if (!request.isKeepAlive()) {
    conn.setRequestProperty("String_Node_Str","String_Node_Str");
  }
  try {
    conn.connect();
  }
 catch (  IOException e) {
    throw new RequestsException(e);
  }
  try {
    if (body != null) {
      sendBody(body,conn,charset);
    }
    return getResponse(url,conn,cookieJar,request.isCompress(),request.getMethod());
  }
 catch (  IOException e) {
    conn.disconnect();
    throw new RequestsException(e);
  }
catch (  Throwable e) {
    conn.disconnect();
    throw e;
  }
}

Fixed version (ground truth):
private RawResponse doRequest(Request request){
  Charset charset=request.getCharset();
  URL url=URIEncoder.joinUrl(request.getUrl(),URIEncoder.toStringParameters(request.getParams()),request.getCharset());
  @Nullable RequestBody body=request.getBody();
  @Nullable URLConnectionSessionContext sessionContext=(URLConnectionSessionContext)request.getSessionContext();
  CookieJar cookieJar;
  if (sessionContext == null) {
    cookieJar=NopCookieJar.instance;
  }
 else {
    cookieJar=sessionContext.getCookieJar();
  }
  HttpURLConnection conn;
  try {
    @Nullable Proxy proxy=request.getProxy();
    if (proxy != null) {
      conn=(HttpURLConnection)url.openConnection(proxy);
    }
 else {
      conn=(HttpURLConnection)url.openConnection();
    }
  }
 catch (  IOException e) {
    throw new RequestsException(e);
  }
  conn.setUseCaches(false);
  if (conn instanceof HttpsURLConnection) {
    SSLSocketFactory ssf=null;
    if (!request.isVerify()) {
      ssf=SSLSocketFactories.getTrustAllSSLSocketFactory();
      ((HttpsURLConnection)conn).setHostnameVerifier(NopHostnameVerifier.getInstance());
    }
 else     if (!request.getCerts().isEmpty()) {
      ssf=SSLSocketFactories.getCustomSSLSocketFactory(request.getCerts());
    }
    if (ssf != null) {
      ((HttpsURLConnection)conn).setSSLSocketFactory(ssf);
    }
  }
  try {
    conn.setRequestMethod(request.getMethod());
  }
 catch (  ProtocolException e) {
    throw new RequestsException(e);
  }
  conn.setReadTimeout(request.getSocksTimeout());
  conn.setConnectTimeout(request.getConnectTimeout());
  conn.setInstanceFollowRedirects(false);
  if (body != null) {
    conn.setDoOutput(true);
    String contentType=body.getContentType();
    if (contentType != null) {
      if (body.isIncludeCharset()) {
        contentType+="String_Node_Str" + request.getCharset().name().toLowerCase();
      }
      conn.setRequestProperty(NAME_CONTENT_TYPE,contentType);
    }
  }
  if (!request.getUserAgent().isEmpty()) {
    conn.setRequestProperty(NAME_USER_AGENT,request.getUserAgent());
  }
  if (request.isCompress()) {
    conn.setRequestProperty(NAME_ACCEPT_ENCODING,"String_Node_Str");
  }
  if (request.getBasicAuth() != null) {
    conn.setRequestProperty(NAME_AUTHORIZATION,request.getBasicAuth().encode());
  }
  Collection<Cookie> sessionCookies=cookieJar.getCookies(url);
  if (!request.getCookies().isEmpty() || !sessionCookies.isEmpty()) {
    StringBuilder sb=new StringBuilder();
    for (    Map.Entry<String,?> entry : request.getCookies()) {
      sb.append(entry.getKey()).append("String_Node_Str").append(String.valueOf(entry.getValue())).append("String_Node_Str");
    }
    for (    Cookie cookie : sessionCookies) {
      sb.append(cookie.getName()).append("String_Node_Str").append(cookie.getValue()).append("String_Node_Str");
    }
    if (sb.length() > 2) {
      sb.setLength(sb.length() - 2);
      String cookieStr=sb.toString();
      conn.setRequestProperty(NAME_COOKIE,cookieStr);
    }
  }
  for (  Map.Entry<String,?> header : request.getHeaders()) {
    conn.setRequestProperty(header.getKey(),String.valueOf(header.getValue()));
  }
  if (!request.isKeepAlive()) {
    conn.setRequestProperty("String_Node_Str","String_Node_Str");
  }
  try {
    conn.connect();
  }
 catch (  IOException e) {
    throw new RequestsException(e);
  }
  try {
    if (body != null) {
      sendBody(body,conn,charset);
    }
    return getResponse(url,conn,cookieJar,request.isCompress(),request.getMethod());
  }
 catch (  IOException e) {
    conn.disconnect();
    throw new RequestsException(e);
  }
catch (  Throwable e) {
    conn.disconnect();
    throw e;
  }
}