Program: 68929
Project: 68929
Buggy source:
private static HttpRequestBase prepareRequest(HttpRequest request,boolean async){
  Object defaultHeaders=Options.getOption(Option.DEFAULT_HEADERS);
  if (defaultHeaders != null) {
    @SuppressWarnings("String_Node_Str") Set<Entry<String,String>> entrySet=((Map<String,String>)defaultHeaders).entrySet();
    for (    Entry<String,String> entry : entrySet) {
      request.header(entry.getKey(),entry.getValue());
    }
  }
  if (!request.getHeaders().containsKey(USER_AGENT_HEADER)) {
    request.header(USER_AGENT_HEADER,USER_AGENT);
  }
  if (!request.getHeaders().containsKey(ACCEPT_ENCODING_HEADER)) {
    request.header(ACCEPT_ENCODING_HEADER,"String_Node_Str");
  }
  HttpRequestBase reqObj=null;
  String urlToRequest=null;
  try {
    URL url=new URL(request.getUrl());
    URI uri=new URI(url.getProtocol(),url.getUserInfo(),url.getHost(),url.getPort(),URLDecoder.decode(url.getPath(),"String_Node_Str"),"String_Node_Str",url.getRef());
    urlToRequest=uri.toURL().toString();
    if (url.getQuery() != null && !url.getQuery().trim().equals("String_Node_Str")) {
      if (!urlToRequest.substring(urlToRequest.length() - 1).equals("String_Node_Str")) {
        urlToRequest+="String_Node_Str";
      }
      urlToRequest+=url.getQuery();
    }
 else     if (urlToRequest.substring(urlToRequest.length() - 1).equals("String_Node_Str")) {
      urlToRequest=urlToRequest.substring(0,urlToRequest.length() - 1);
    }
  }
 catch (  Exception e) {
    throw new RuntimeException(e);
  }
switch (request.getHttpMethod()) {
case GET:
    reqObj=new HttpGet(urlToRequest);
  break;
case POST:
reqObj=new HttpPost(urlToRequest);
break;
case PUT:
reqObj=new HttpPut(urlToRequest);
break;
case DELETE:
reqObj=new HttpDeleteWithBody(urlToRequest);
break;
case PATCH:
reqObj=new HttpPatchWithBody(urlToRequest);
break;
case OPTIONS:
reqObj=new HttpOptions(urlToRequest);
break;
case HEAD:
reqObj=new HttpHead(urlToRequest);
break;
}
Set<Entry<String,List<String>>> entrySet=request.getHeaders().entrySet();
for (Entry<String,List<String>> entry : entrySet) {
List<String> values=entry.getValue();
if (values != null) {
for (String value : values) {
reqObj.addHeader(entry.getKey(),value);
}
}
}
if (!(request.getHttpMethod() == HttpMethod.GET || request.getHttpMethod() == HttpMethod.HEAD)) {
if (request.getBody() != null) {
HttpEntity entity=request.getBody().getEntity();
if (async) {
if (reqObj.getHeaders(CONTENT_TYPE) == null || reqObj.getHeaders(CONTENT_TYPE).length == 0) {
reqObj.setHeader(entity.getContentType());
}
try {
ByteArrayOutputStream output=new ByteArrayOutputStream();
entity.writeTo(output);
NByteArrayEntity en=new NByteArrayEntity(output.toByteArray());
((HttpEntityEnclosingRequestBase)reqObj).setEntity(en);
}
 catch (IOException e) {
throw new RuntimeException(e);
}
}
 else {
((HttpEntityEnclosingRequestBase)reqObj).setEntity(entity);
}
}
}
return reqObj;
}

Fixed version (ground truth):
private static HttpRequestBase prepareRequest(HttpRequest request,boolean async){
  Object defaultHeaders=Options.getOption(Option.DEFAULT_HEADERS);
  if (defaultHeaders != null) {
    @SuppressWarnings("String_Node_Str") Set<Entry<String,String>> entrySet=((Map<String,String>)defaultHeaders).entrySet();
    for (    Entry<String,String> entry : entrySet) {
      request.header(entry.getKey(),entry.getValue());
    }
  }
  if (!request.getHeaders().containsKey(USER_AGENT_HEADER)) {
    request.header(USER_AGENT_HEADER,USER_AGENT);
  }
  if (!request.getHeaders().containsKey(ACCEPT_ENCODING_HEADER)) {
    request.header(ACCEPT_ENCODING_HEADER,"String_Node_Str");
  }
  HttpRequestBase reqObj=null;
  String urlToRequest=uriFormatter.apply(request);
switch (request.getHttpMethod()) {
case GET:
    reqObj=new HttpGet(urlToRequest);
  break;
case POST:
reqObj=new HttpPost(urlToRequest);
break;
case PUT:
reqObj=new HttpPut(urlToRequest);
break;
case DELETE:
reqObj=new HttpDeleteWithBody(urlToRequest);
break;
case PATCH:
reqObj=new HttpPatchWithBody(urlToRequest);
break;
case OPTIONS:
reqObj=new HttpOptions(urlToRequest);
break;
case HEAD:
reqObj=new HttpHead(urlToRequest);
break;
}
Set<Entry<String,List<String>>> entrySet=request.getHeaders().entrySet();
for (Entry<String,List<String>> entry : entrySet) {
List<String> values=entry.getValue();
if (values != null) {
for (String value : values) {
reqObj.addHeader(entry.getKey(),value);
}
}
}
if (!(request.getHttpMethod() == HttpMethod.GET || request.getHttpMethod() == HttpMethod.HEAD)) {
if (request.getBody() != null) {
HttpEntity entity=request.getBody().getEntity();
if (async) {
if (reqObj.getHeaders(CONTENT_TYPE) == null || reqObj.getHeaders(CONTENT_TYPE).length == 0) {
reqObj.setHeader(entity.getContentType());
}
try {
ByteArrayOutputStream output=new ByteArrayOutputStream();
entity.writeTo(output);
NByteArrayEntity en=new NByteArrayEntity(output.toByteArray());
((HttpEntityEnclosingRequestBase)reqObj).setEntity(en);
}
 catch (IOException e) {
throw new RuntimeException(e);
}
}
 else {
((HttpEntityEnclosingRequestBase)reqObj).setEntity(entity);
}
}
}
return reqObj;
}