nus-yam/ex-repair huggingface dataset:
Program: 7571
Project: 7571
Buggy source:
public static boolean verify(String url,String authorizationHeader,OAuthConsumer consumer,OAuthAccessToken accessToken,HttpMethod httpMethod,SignatureMethod signatureMethod){
  if (authorizationHeader == null) {
    return false;
  }
  Map<String,String> elements=parseAuthorizationHeader(authorizationHeader);
  SignedRequest req=SignedRequestFactory.create(consumer,accessToken,signatureMethod);
  String signature=req.getSignature(url,httpMethod,elements.get("String_Node_Str"),Long.valueOf(elements.get("String_Node_Str")));
  return OAuthEncoding.encode(signature).equals(elements.get("String_Node_Str"));
}

Fixed version (ground truth):
public static boolean verify(String url,String authorizationHeader,OAuthConsumer consumer,OAuthAccessToken accessToken,HttpMethod httpMethod,SignatureMethod signatureMethod){
  if (authorizationHeader == null) {
    return false;
  }
  Map<String,String> elements=parseAuthorizationHeader(authorizationHeader);
  SignedRequest req=SignedRequestFactory.create(consumer,accessToken,signatureMethod);
  Map<String,Object> additionalParams=new HashMap<String,Object>();
  for (  String name : elements.keySet()) {
    String _name=name.replaceFirst("String_Node_Str","String_Node_Str");
    if (!oAuthElementNames.contains(_name)) {
      additionalParams.put(name,OAuthEncoding.decode(elements.get(name)));
    }
  }
  req.setAdditionalAuthorizationHeaderParams(additionalParams);
  String signature=req.getSignature(url,httpMethod,elements.get("String_Node_Str"),Long.valueOf(elements.get("String_Node_Str")));
  return OAuthEncoding.encode(signature).equals(elements.get("String_Node_Str"));
}
Program: 7572
Project: 7572
Buggy source:
public static void main(String[] args) throws Exception {
  Map<String,Object> additionalParams=new HashMap<String,Object>();
  additionalParams.put("String_Node_Str","String_Node_Str");
  SignedRequest signedRequest=SignedRequestFactory.create(new OAuthConsumer("String_Node_Str","String_Node_Str"),new OAuthAccessToken("String_Node_Str","String_Node_Str"),additionalParams);
  String signature=signedRequest.getSignature("String_Node_Str",HttpMethod.GET,"String_Node_Str",1272026745L);
  if ("String_Node_Str".equals(signature)) {
    System.out.println("String_Node_Str");
  }
}

Fixed version (ground truth):
public static void main(String[] args) throws Exception {
  OAuthConsumer consumer=new OAuthConsumer("String_Node_Str","String_Node_Str");
  Map<String,Object> additionalParams=new HashMap<String,Object>();
  additionalParams.put("String_Node_Str","String_Node_Str");
  String url="String_Node_Str";
  HttpMethod httpMethod=HttpMethod.GET;
  SignatureMethod signatureMethod=SignatureMethod.HMAC_SHA1;
  String oAuthNonce="String_Node_Str";
  Long oAuthTimestamp=1272026745L;
{
    SignedRequest signedRequest=SignedRequestFactory.create(consumer,additionalParams);
    String signature=signedRequest.getSignature(url,httpMethod,oAuthNonce,oAuthTimestamp);
    String authorizationHeader=signedRequest.getAuthorizationHeader(signature,oAuthNonce,oAuthTimestamp);
    System.out.println(authorizationHeader);
    boolean isValid=SignedRequestVerifier.verify(url,authorizationHeader,consumer,httpMethod,signatureMethod);
    if (isValid) {
      System.out.println("String_Node_Str");
    }
  }
  OAuthAccessToken accessToken=new OAuthAccessToken("String_Node_Str","String_Node_Str");
{
    SignedRequest signedRequest=SignedRequestFactory.create(consumer,accessToken,additionalParams);
    String signature=signedRequest.getSignature(url,httpMethod,oAuthNonce,oAuthTimestamp);
    String authorizationHeader=signedRequest.getAuthorizationHeader(signature,oAuthNonce,oAuthTimestamp);
    System.out.println(authorizationHeader);
    boolean isValid=SignedRequestVerifier.verify(url,authorizationHeader,consumer,accessToken,httpMethod,signatureMethod);
    if (isValid) {
      System.out.println("String_Node_Str");
    }
  }
}
Program: 7573
Project: 7573
Buggy source:
public static boolean verify(String url,String authorizationHeader,OAuthConsumer consumer,OAuthAccessToken accessToken,HttpMethod httpMethod,SignatureMethod signatureMethod){
  if (authorizationHeader == null) {
    return false;
  }
  Map<String,String> elements=parseAuthorizationHeader(authorizationHeader);
  SignedRequest req=SignedRequestFactory.create(consumer,accessToken,signatureMethod);
  Map<String,Object> additionalParams=new HashMap<String,Object>();
  for (  String name : elements.keySet()) {
    String _name=name.replaceFirst("String_Node_Str","String_Node_Str");
    if (!oAuthElementNames.contains(_name)) {
      additionalParams.put(name,OAuthEncoding.decode(elements.get(name)));
    }
  }
  req.setAdditionalAuthorizationHeaderParams(additionalParams);
  String signature=req.getSignature(url,httpMethod,elements.get("String_Node_Str"),Long.valueOf(elements.get("String_Node_Str")));
  return OAuthEncoding.encode(signature).equals(elements.get("String_Node_Str"));
}

Fixed version (ground truth):
public static boolean verify(String url,String authorizationHeader,OAuthConsumer consumer,OAuthAccessToken accessToken,HttpMethod httpMethod,SignatureMethod signatureMethod){
  if (authorizationHeader == null) {
    return false;
  }
  if (httpMethod.equals(HttpMethod.POST)) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  Map<String,String> elements=parseAuthorizationHeader(authorizationHeader);
  SignedRequest req=SignedRequestFactory.create(consumer,accessToken,signatureMethod);
  Map<String,Object> additionalParams=new HashMap<String,Object>();
  for (  String name : elements.keySet()) {
    String _name=name.replaceFirst("String_Node_Str","String_Node_Str");
    if (!oAuthElementNames.contains(_name)) {
      additionalParams.put(name,OAuthEncoding.decode(elements.get(name)));
    }
  }
  req.setAdditionalAuthorizationHeaderParams(additionalParams);
  String signature=req.getSignature(url,httpMethod,elements.get("String_Node_Str"),Long.valueOf(elements.get("String_Node_Str")));
  return OAuthEncoding.encode(signature).equals(elements.get("String_Node_Str"));
}
Program: 7575
Project: 7575
Buggy source:
List<Parameter> getNormalizedParameters(String oAuthNonce,Long oAuthTimestamp){
  List<Parameter> params=new ArrayList<Parameter>();
  params.add(new Parameter("String_Node_Str",consumer.getConsumerKey()));
  if (accessToken != null) {
    params.add(new Parameter("String_Node_Str",accessToken.getToken()));
  }
  params.add(new Parameter("String_Node_Str",oAuthNonce));
  params.add(new Parameter("String_Node_Str",signatureMethod));
  params.add(new Parameter("String_Node_Str",oAuthTimestamp));
  params.add(new Parameter("String_Node_Str",oAuthVersion));
  if (additionalParameters != null && additionalParameters.size() > 0) {
    for (    String key : additionalParameters.keySet()) {
      params.add(new Parameter(key,OAuthEncoding.encode(additionalParameters.get(key))));
    }
  }
  Collections.sort(params,new Comparator<Parameter>(){
    public int compare(    Parameter p1,    Parameter p2){
      return p1.getKey().compareTo(p2.getKey());
    }
  }
);
  return params;
}

Fixed version (ground truth):
List<Parameter> getNormalizedParameters(String oAuthNonce,Long oAuthTimestamp){
  List<Parameter> params=new ArrayList<Parameter>();
  params.add(new Parameter("String_Node_Str",consumer.getConsumerKey()));
  if (accessToken != null) {
    params.add(new Parameter("String_Node_Str",accessToken.getToken()));
  }
  params.add(new Parameter("String_Node_Str",oAuthNonce));
  params.add(new Parameter("String_Node_Str",signatureMethod));
  params.add(new Parameter("String_Node_Str",oAuthTimestamp));
  params.add(new Parameter("String_Node_Str",oAuthVersion));
  if (additionalParameters != null && additionalParameters.size() > 0) {
    for (    String key : additionalParameters.keySet()) {
      Object parameter=additionalParameters.get(key);
      if (parameter != null) {
        params.add(new Parameter(key,OAuthEncoding.encode(parameter)));
      }
    }
  }
  Collections.sort(params,new Comparator<Parameter>(){
    public int compare(    Parameter p1,    Parameter p2){
      return p1.getKey().compareTo(p2.getKey());
    }
  }
);
  return params;
}
Program: 7576
Project: 7576
Buggy source:
public static boolean verifyPOST(String url,String authorizationHeader,OAuthConsumer consumer,OAuthAccessToken accessToken,SignatureMethod signatureMethod,Map<String,Object> formParams){
  if (authorizationHeader == null) {
    return false;
  }
  Map<String,String> elements=parseAuthorizationHeader(authorizationHeader);
  for (  String key : formParams.keySet()) {
    elements.put(key,formParams.get(key).toString());
  }
  SignedRequest req=SignedRequestFactory.create(consumer,accessToken,signatureMethod);
  Map<String,Object> additionalParams=new HashMap<String,Object>();
  for (  String name : elements.keySet()) {
    String _name=name.replaceFirst("String_Node_Str","String_Node_Str");
    if (!oAuthElementNames.contains(_name)) {
      additionalParams.put(name,OAuthEncoding.decode(elements.get(name)));
    }
  }
  req.setAdditionalAuthorizationHeaderParams(additionalParams);
  String signature=req.getSignature(url,HttpMethod.POST,elements.get("String_Node_Str"),Long.valueOf(elements.get("String_Node_Str")));
  return OAuthEncoding.encode(signature).equals(elements.get("String_Node_Str"));
}

Fixed version (ground truth):
public static boolean verifyPOST(String url,String authorizationHeader,OAuthConsumer consumer,OAuthAccessToken accessToken,SignatureMethod signatureMethod,Map<String,Object> formParams){
  if (authorizationHeader == null) {
    return false;
  }
  Map<String,String> elements=parseAuthorizationHeader(authorizationHeader);
  for (  String key : formParams.keySet()) {
    Object value=formParams.get(key);
    if (value != null) {
      elements.put(key,value.toString());
    }
  }
  SignedRequest req=SignedRequestFactory.create(consumer,accessToken,signatureMethod);
  Map<String,Object> additionalParams=new HashMap<String,Object>();
  for (  String name : elements.keySet()) {
    String _name=name.replaceFirst("String_Node_Str","String_Node_Str");
    if (!oAuthElementNames.contains(_name)) {
      additionalParams.put(name,OAuthEncoding.decode(elements.get(name)));
    }
  }
  req.setAdditionalAuthorizationHeaderParams(additionalParams);
  String signature=req.getSignature(url,HttpMethod.POST,elements.get("String_Node_Str"),Long.valueOf(elements.get("String_Node_Str")));
  return OAuthEncoding.encode(signature).equals(elements.get("String_Node_Str"));
}
Program: 7577
Project: 7577
Buggy source:
public static Map<String,String> parseAuthorizationHeader(String authorizationHeader){
  Map<String,String> elements=new HashMap<String,String>();
  String[] keyAndValueArray=authorizationHeader.split("String_Node_Str");
  for (  String keyAndValue : keyAndValueArray) {
    String[] arr=keyAndValue.replaceAll("String_Node_Str","String_Node_Str").split("String_Node_Str");
    elements.put(arr[0].trim(),arr[1].trim());
  }
  return elements;
}

Fixed version (ground truth):
public static Map<String,String> parseAuthorizationHeader(String authorizationHeader){
  Map<String,String> elements=new HashMap<String,String>();
  String[] keyAndValueArray=authorizationHeader.split("String_Node_Str");
  for (  String keyAndValue : keyAndValueArray) {
    String[] arr=keyAndValue.split("String_Node_Str");
    String key=arr[0].trim().replaceAll("String_Node_Str","String_Node_Str");
    String value=arr[1].trim().replaceAll("String_Node_Str","String_Node_Str");
    elements.put(key,value);
  }
  return elements;
}
Program: 7578
Project: 7578
Buggy source:
@Test public void doRequest_A$String$HttpMethod$Map$String() throws Exception {
  OAuthRealm realm=null;
  OAuthConsumer consumer=new OAuthConsumer("String_Node_Str","String_Node_Str");
  SignatureMethod signatureMethod=SignatureMethod.HMAC_SHA1;
  SignedRequestApacheHCImpl target=new SignedRequestApacheHCImpl(realm,consumer,signatureMethod);
  String url="String_Node_Str";
  HttpMethod method=HttpMethod.GET;
  Map<String,Object> requestParameters=new HashMap<String,Object>();
  requestParameters.put("String_Node_Str","String_Node_Str");
  String charset="String_Node_Str";
  HttpResponse actual=target.doRequest(url,method,requestParameters,charset);
  assertNotNull(actual);
}

Fixed version (ground truth):
@Test public void doRequest_A$String$HttpMethod$Map$String() throws Exception {
  OAuthRealm realm=null;
  OAuthConsumer consumer=new OAuthConsumer("String_Node_Str","String_Node_Str");
  SignatureMethod signatureMethod=SignatureMethod.HMAC_SHA1;
  SignedRequestApacheHCImpl target=new SignedRequestApacheHCImpl(realm,consumer,signatureMethod);
  String url="String_Node_Str";
  HttpMethod method=HttpMethod.GET;
  Map<String,Object> requestParameters=new HashMap<String,Object>();
  requestParameters.put("String_Node_Str","String_Node_Str");
  requestParameters.put("String_Node_Str",null);
  String charset="String_Node_Str";
  HttpResponse actual=target.doRequest(url,method,requestParameters,charset);
  assertNotNull(actual);
}
Program: 7579
Project: 7579
Buggy source:
public void _handle(Boolean isAllowed,HttpMethod method,Request baseRequest,HttpServletRequest request,HttpServletResponse response) throws Exception {
  boolean isValid=SignedRequestVerifier.verify("String_Node_Str",request.getHeader("String_Node_Str"),HttpServerSpec.SINGLETON_CONSUMER,method,SignatureMethod.HMAC_SHA1);
  if (isAllowed && isValid) {
    response.setStatus(HttpServletResponse.SC_OK);
  }
 else {
    response.setStatus(HttpServletResponse.SC_FORBIDDEN);
  }
  response.getWriter().print("String_Node_Str");
  baseRequest.setHandled(true);
}

Fixed version (ground truth):
public void _handle(Boolean isAllowed,HttpMethod method,Request baseRequest,HttpServletRequest request,HttpServletResponse response) throws Exception {
  boolean isValid=false;
  if (method.equals(HttpMethod.POST)) {
    isValid=SignedRequestVerifier.verifyPOST("String_Node_Str",request.getHeader("String_Node_Str"),HttpServerSpec.SINGLETON_CONSUMER,SignatureMethod.HMAC_SHA1,request.getParameterMap());
  }
 else {
    isValid=SignedRequestVerifier.verify("String_Node_Str",request.getHeader("String_Node_Str"),HttpServerSpec.SINGLETON_CONSUMER,method,SignatureMethod.HMAC_SHA1);
  }
  if (isAllowed && isValid) {
    response.setStatus(HttpServletResponse.SC_OK);
  }
 else {
    response.setStatus(HttpServletResponse.SC_FORBIDDEN);
  }
  response.getWriter().print("String_Node_Str");
  baseRequest.setHandled(true);
}
Program: 7581
Project: 7581
Buggy source:
@Test public void doPut_A$String() throws Exception {
  final HttpServer deleteServer=new HttpServer(new PutHandler());
  try {
    Runnable runnable=new Runnable(){
      @Override public void run(){
        deleteServer.start();
      }
    }
;
    new Thread(runnable).start();
    OAuthRealm realm=null;
    SignatureMethod signatureMethod=SignatureMethod.HMAC_SHA1;
    SignedRequest request=new SignedRequestImpl(realm,HttpServerSpec.SINGLETON_CONSUMER(),signatureMethod);
    request.doPut("String_Node_Str");
  }
  finally {
    deleteServer.stop();
  }
}

Fixed version (ground truth):
@Test public void doPut_A$String() throws Exception {
  final HttpServer server=new HttpServer(new PutHandler());
  try {
    Runnable runnable=new Runnable(){
      @Override public void run(){
        try {
          server.start();
        }
 catch (        Exception e) {
          e.printStackTrace();
        }
      }
    }
;
    new Thread(runnable).start();
    OAuthRealm realm=null;
    SignatureMethod signatureMethod=SignatureMethod.HMAC_SHA1;
    SignedRequest request=new SignedRequestImpl(realm,HttpServerSpec.SINGLETON_CONSUMER,signatureMethod);
    request.doPut("String_Node_Str");
  }
  finally {
    server.stop();
  }
}
Program: 7582
Project: 7582
Buggy source:
@Override public void run(){
  deleteServer.start();
}

Fixed version (ground truth):
@Override public void run(){
  try {
    server.start();
  }
 catch (  Exception e) {
    e.printStackTrace();
  }
}
Program: 7583
Project: 7583
Buggy source:
@Test public void doTrace_A$String() throws Exception {
  final HttpServer deleteServer=new HttpServer(new TraceHandler());
  try {
    Runnable runnable=new Runnable(){
      @Override public void run(){
        deleteServer.start();
      }
    }
;
    new Thread(runnable).start();
    OAuthRealm realm=null;
    SignatureMethod signatureMethod=SignatureMethod.HMAC_SHA1;
    SignedRequest request=new SignedRequestImpl(realm,HttpServerSpec.SINGLETON_CONSUMER(),signatureMethod);
    request.doTrace("String_Node_Str");
  }
  finally {
    deleteServer.stop();
  }
}

Fixed version (ground truth):
@Test public void doTrace_A$String() throws Exception {
  final HttpServer server=new HttpServer(new TraceHandler());
  try {
    Runnable runnable=new Runnable(){
      @Override public void run(){
        try {
          server.start();
        }
 catch (        Exception e) {
          e.printStackTrace();
        }
      }
    }
;
    new Thread(runnable).start();
    OAuthRealm realm=null;
    SignatureMethod signatureMethod=SignatureMethod.HMAC_SHA1;
    SignedRequest request=new SignedRequestImpl(realm,HttpServerSpec.SINGLETON_CONSUMER,signatureMethod);
    request.doTrace("String_Node_Str");
  }
  finally {
    server.stop();
  }
}
Program: 7584
Project: 7584
Buggy source:
@Test public void doDelete_A$String() throws Exception {
  final HttpServer deleteServer=new HttpServer(new DeleteHandler());
  try {
    Runnable runnable=new Runnable(){
      @Override public void run(){
        deleteServer.start();
      }
    }
;
    new Thread(runnable).start();
    OAuthRealm realm=null;
    SignatureMethod signatureMethod=SignatureMethod.HMAC_SHA1;
    SignedRequest request=new SignedRequestImpl(realm,HttpServerSpec.SINGLETON_CONSUMER(),signatureMethod);
    request.doDelete("String_Node_Str");
  }
  finally {
    deleteServer.stop();
  }
}

Fixed version (ground truth):
@Test public void doDelete_A$String() throws Exception {
  final HttpServer server=new HttpServer(new DeleteHandler());
  try {
    Runnable runnable=new Runnable(){
      @Override public void run(){
        try {
          server.start();
        }
 catch (        Exception e) {
          e.printStackTrace();
        }
      }
    }
;
    new Thread(runnable).start();
    OAuthRealm realm=null;
    SignatureMethod signatureMethod=SignatureMethod.HMAC_SHA1;
    SignedRequest request=new SignedRequestImpl(realm,HttpServerSpec.SINGLETON_CONSUMER,signatureMethod);
    request.doDelete("String_Node_Str");
  }
  finally {
    server.stop();
  }
}
Program: 7586
Project: 7586
Buggy source:
/** 
 * {@inheritDoc}
 */
@Override public HttpURLConnection getHttpURLConnection(String url,HttpMethod method) throws IOException {
  String oAuthNonce=String.valueOf(new SecureRandom().nextLong());
  Long oAuthTimestamp=System.currentTimeMillis();
  String signature=getSignature(url,method,oAuthNonce,oAuthTimestamp);
  String authorizationHeader=getAuthorizationHeader(signature,oAuthNonce,oAuthTimestamp);
  HttpURLConnection conn=(HttpURLConnection)new URL(url).openConnection();
  conn.setConnectTimeout(3000);
  conn.setReadTimeout(10000);
  conn.setRequestProperty("String_Node_Str","String_Node_Str");
  conn.setRequestMethod(method.toString());
  conn.setRequestProperty("String_Node_Str",authorizationHeader);
  return conn;
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 */
@Override public HttpURLConnection getHttpURLConnection(String url,HttpMethod method) throws IOException {
  String oAuthNonce=String.valueOf(new SecureRandom().nextLong());
  Long oAuthTimestamp=System.currentTimeMillis() / 1000;
  String signature=getSignature(url,method,oAuthNonce,oAuthTimestamp);
  String authorizationHeader=getAuthorizationHeader(signature,oAuthNonce,oAuthTimestamp);
  HttpURLConnection conn=(HttpURLConnection)new URL(url).openConnection();
  conn.setConnectTimeout(3000);
  conn.setReadTimeout(10000);
  conn.setRequestProperty("String_Node_Str","String_Node_Str");
  conn.setRequestMethod(method.toString());
  conn.setRequestProperty("String_Node_Str",authorizationHeader);
  return conn;
}
Program: 7587
Project: 7587
Buggy source:
@Test public void doRequest_A$String$HttpMethod$Map$String_TwitterOAuth() throws Exception {
  String realm="String_Node_Str";
  Properties props=new Properties();
  props.load(this.getClass().getClassLoader().getResourceAsStream("String_Node_Str"));
  String consumerKey=(String)props.get("String_Node_Str");
  String consumerSecret=(String)props.get("String_Node_Str");
  OAuthConsumer consumer=new OAuthConsumer(consumerKey,consumerSecret);
  String token=(String)props.get("String_Node_Str");
  String tokenSecret=(String)props.get("String_Node_Str");
  OAuthToken accessToken=new OAuthToken(token,tokenSecret);
  SignatureMethod signatureMethod=SignatureMethod.HMAC_SHA1;
  SignedRequestImpl target=new SignedRequestImpl(realm,consumer,accessToken,signatureMethod);
  String url="String_Node_Str";
  HttpMethod method=HttpMethod.GET;
  String charset="String_Node_Str";
}

Fixed version (ground truth):
@Test public void doRequest_A$String$HttpMethod$Map$String_TwitterOAuth() throws Exception {
  String realm="String_Node_Str";
  Properties props=new Properties();
  props.load(this.getClass().getClassLoader().getResourceAsStream("String_Node_Str"));
  String consumerKey=(String)props.get("String_Node_Str");
  String consumerSecret=(String)props.get("String_Node_Str");
  OAuthConsumer consumer=new OAuthConsumer(consumerKey,consumerSecret);
  String token=(String)props.get("String_Node_Str");
  String tokenSecret=(String)props.get("String_Node_Str");
  OAuthToken accessToken=new OAuthToken(token,tokenSecret);
  SignatureMethod signatureMethod=SignatureMethod.HMAC_SHA1;
  SignedRequestImpl target=new SignedRequestImpl(realm,consumer,accessToken,signatureMethod);
  String url="String_Node_Str";
  HttpMethod method=HttpMethod.GET;
  String charset="String_Node_Str";
  HttpResponse actual=target.doRequest(url,method,null,charset);
  assertNotNull(actual);
  System.out.println(actual.getHeaders());
  System.out.println(actual.getContent());
}
Program: 7588
Project: 7588
Buggy source:
String getResponseCotent(HttpURLConnection conn,String charset) throws IOException {
  InputStream is=null;
  BufferedReader br=null;
  try {
    is=conn.getInputStream();
    br=new BufferedReader(new InputStreamReader(is,charset));
    StringBuilder buf=new StringBuilder();
    String line=null;
    while ((line=br.readLine()) != null) {
      buf.append(line);
      buf.append("String_Node_Str");
    }
    return buf.toString();
  }
  finally {
    if (is != null) {
      try {
        is.close();
      }
 catch (      Exception e2) {
      }
    }
    if (br != null) {
      try {
        br.close();
      }
 catch (      Exception e2) {
      }
    }
  }
}

Fixed version (ground truth):
String getResponseCotent(HttpURLConnection conn,String charset) throws IOException {
  InputStream is=null;
  BufferedReader br=null;
  try {
    is=conn.getInputStream();
    Reader isr=(charset != null) ? new InputStreamReader(is,charset) : new InputStreamReader(is);
    br=new BufferedReader(isr);
    StringBuilder buf=new StringBuilder();
    String line=null;
    while ((line=br.readLine()) != null) {
      buf.append(line);
      buf.append("String_Node_Str");
    }
    return buf.toString();
  }
  finally {
    if (is != null) {
      try {
        is.close();
      }
 catch (      Exception e2) {
      }
    }
    if (br != null) {
      try {
        br.close();
      }
 catch (      Exception e2) {
      }
    }
  }
}
Program: 7589
Project: 7589
Buggy source:
String getAuthorizationHeader(String signature,String oAuthNonce,Long oAuthTimestamp){
  StringBuilder buf=new StringBuilder();
  buf.append("String_Node_Str");
  if (realm != null) {
    buf.append("String_Node_Str" + realm + "String_Node_Str");
  }
  buf.append("String_Node_Str" + consumerKey + "String_Node_Str");
  buf.append("String_Node_Str" + signatureMethod + "String_Node_Str");
  buf.append("String_Node_Str" + signature + "String_Node_Str");
  buf.append("String_Node_Str" + oAuthTimestamp + "String_Node_Str");
  buf.append("String_Node_Str" + oAuthNonce + "String_Node_Str");
  buf.append("String_Node_Str" + oAuthVersion + "String_Node_Str");
  if (additionalParameters != null && additionalParameters.size() > 0) {
    for (    String key : additionalParameters.keySet()) {
      buf.append(key + "String_Node_Str" + additionalParameters.get(key)+ "String_Node_Str");
    }
  }
  return buf.toString();
}

Fixed version (ground truth):
String getAuthorizationHeader(String signature,String oAuthNonce,Long oAuthTimestamp){
  StringBuilder buf=new StringBuilder();
  buf.append("String_Node_Str");
  if (realm != null) {
    buf.append("String_Node_Str" + realm + "String_Node_Str");
  }
  if (token != null) {
    buf.append("String_Node_Str" + token + "String_Node_Str");
  }
  buf.append("String_Node_Str" + consumerKey + "String_Node_Str");
  buf.append("String_Node_Str" + signatureMethod + "String_Node_Str");
  buf.append("String_Node_Str" + signature + "String_Node_Str");
  buf.append("String_Node_Str" + oAuthTimestamp + "String_Node_Str");
  buf.append("String_Node_Str" + oAuthNonce + "String_Node_Str");
  buf.append("String_Node_Str" + oAuthVersion + "String_Node_Str");
  if (additionalParameters != null && additionalParameters.size() > 0) {
    for (    String key : additionalParameters.keySet()) {
      buf.append(key + "String_Node_Str" + additionalParameters.get(key)+ "String_Node_Str");
    }
  }
  return buf.toString();
}
Program: 7590
Project: 7590
Buggy source:
/** 
 * Do HTTP request and returns Http response
 * @param url               Request URL
 * @param method            HTTP Method
 * @param requestParameters Request parameters(OPTIONAL)
 * @param charset           Charset
 * @return HTTP Response
 * @throws IOException
 */
HttpResponse doRequest(String url,HttpMethod method,Map<String,Object> requestParameters,String charset) throws IOException ;

Fixed version (ground truth):
/** 
 * Do HTTP request and returns Http response
 * @param url Request URL
 * @param method HTTP Method
 * @param requestParameters Request parameters(OPTIONAL)
 * @param charset Charset
 * @return HTTP Response
 * @throws IOException
 */
HttpResponse doRequest(String url,HttpMethod method,Map<String,Object> requestParameters,String charset) throws IOException ;
Program: 7591
Project: 7591
Buggy source:
/** 
 * Do POST / HTTP/1.1 request and returns Http response
 * @param url               Request URL
 * @param requestParameters Request parameters
 * @param charset           Charset
 * @return HTTP Response
 * @throws IOException
 */
HttpResponse doPostRequest(String url,Map<String,Object> requestParameters,String charset) throws IOException ;

Fixed version (ground truth):
/** 
 * Do POST / HTTP/1.1 request and returns Http response
 * @param url Request URL
 * @param requestParameters Request parameters
 * @param charset Charset
 * @return HTTP Response
 * @throws IOException
 */
HttpResponse doPostRequest(String url,Map<String,Object> requestParameters,String charset) throws IOException ;
Program: 7592
Project: 7592
Buggy source:
/** 
 * Returns Signed   {@link HttpURLConnection} instance.
 * @param url    Request URL
 * @param method HTTP Method
 * @return Signed {@link HttpURLConnection} instance
 * @throws IOException
 */
HttpURLConnection getHttpURLConnection(String url,HttpMethod method) throws IOException ;

Fixed version (ground truth):
/** 
 * Returns Signed   {@link HttpURLConnection} instance.
 * @param url Request URL
 * @param method HTTP Method
 * @return Signed {@link HttpURLConnection} instance
 * @throws IOException
 */
HttpURLConnection getHttpURLConnection(String url,HttpMethod method) throws IOException ;
Program: 7593
Project: 7593
Buggy source:
/** 
 * Do GET / HTTP/1.1 request and returns Http response
 * @param url     Request URL
 * @param charset Charset
 * @return HTTP Response
 * @throws IOException
 */
HttpResponse doGetRequest(String url,String charset) throws IOException ;

Fixed version (ground truth):
/** 
 * Do GET / HTTP/1.1 request and returns Http response
 * @param url Request URL
 * @param charset Charset
 * @return HTTP Response
 * @throws IOException
 */
HttpResponse doGetRequest(String url,String charset) throws IOException ;
Program: 7594
Project: 7594
Buggy source:
/** 
 * Returns OAuth Signature.
 * @param url            Request URL
 * @param method         HTTP Method
 * @param oAuthNonce     OAuth Nonce Value
 * @param oAuthTimestamp OAuth Timestamp Value
 * @return OAuth Signature
 */
String getSignature(String url,HttpMethod method,String oAuthNonce,Long oAuthTimestamp);

Fixed version (ground truth):
/** 
 * Returns OAuth Signature.
 * @param url Request URL
 * @param method HTTP Method
 * @param oAuthNonce OAuth Nonce Value
 * @param oAuthTimestamp OAuth Timestamp Value
 * @return OAuth Signature
 */
String getSignature(String url,HttpMethod method,String oAuthNonce,Long oAuthTimestamp);
Program: 7595
Project: 7595
Buggy source:
/** 
 * Returns   {@link SignedRequest} instance.
 * @param realm realm(nullable)
 * @param consumer OAuth consumer
 * @param signatureMethod Signature Method
 * @param additionalParameters Additional parameters(optional)
 * @return {@link SignedRequest} instance.
 */
public static SignedRequest getInstance(String realm,OAuthConsumer consumer,SignatureMethod signatureMethod,Map<String,String> additionalParameters){
  return new SignedRequestImpl(realm,consumer,signatureMethod,additionalParameters);
}

Fixed version (ground truth):
/** 
 * Returns   {@link SignedRequest} instance.
 * @param realm realm(nullable)
 * @param consumer OAuth consumer
 * @param signatureMethod Signature Method
 * @param additionalParameters Additional parameters(optional)
 * @return {@link SignedRequest} instance.
 */
public static SignedRequest getInstance(String realm,OAuthConsumer consumer,SignatureMethod signatureMethod,Map<String,Object> additionalParameters){
  return new SignedRequestImpl(realm,consumer,signatureMethod,additionalParameters);
}
Program: 7596
Project: 7596
Buggy source:
/** 
 * {@inheritDoc}
 */
@Override public HttpResponse doRequest(String url,HttpMethod method,Map<String,Object> requestParameters,String charset) throws IOException {
  HttpResponse response=new HttpResponse();
  HttpURLConnection conn=getHttpURLConnection(url,method);
  if (method == HttpMethod.GET && requestParameters != null && requestParameters.size() > 0) {
    for (    String key : requestParameters.keySet()) {
      String param=key + requestParameters.get(key);
      url+=(url.contains("String_Node_Str") ? "String_Node_Str" : "String_Node_Str") + param;
    }
  }
  if (method == HttpMethod.POST && requestParameters != null && requestParameters.size() > 0) {
    OutputStream os=null;
    OutputStreamWriter writer=null;
    try {
      conn.setDoOutput(true);
      os=conn.getOutputStream();
      writer=new OutputStreamWriter(os);
      for (      String key : requestParameters.keySet()) {
        writer.append(key);
        writer.append("String_Node_Str");
        writer.append(requestParameters.get(key).toString());
      }
    }
  finally {
      if (writer != null) {
        try {
          writer.close();
        }
 catch (        Exception e) {
        }
      }
      if (os != null) {
        try {
          os.close();
        }
 catch (        Exception e) {
        }
      }
    }
  }
  conn.connect();
  response.setStatusCode(conn.getResponseCode());
  response.setHeaders(conn.getHeaderFields());
  response.setContent(getResponseCotent(conn,charset));
  return response;
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 */
@Override public HttpResponse doRequest(String url,HttpMethod method,Map<String,Object> requestParameters,String charset) throws IOException {
  if (method == HttpMethod.GET && requestParameters != null && requestParameters.size() > 0) {
    for (    String key : requestParameters.keySet()) {
      String param=key + "String_Node_Str" + requestParameters.get(key);
      url+=(url.contains("String_Node_Str") ? "String_Node_Str" : "String_Node_Str") + param;
    }
  }
  HttpURLConnection conn=getHttpURLConnection(url,method);
  if (method == HttpMethod.POST && requestParameters != null && requestParameters.size() > 0) {
    OutputStream os=null;
    OutputStreamWriter writer=null;
    try {
      conn.setDoOutput(true);
      os=conn.getOutputStream();
      writer=new OutputStreamWriter(os);
      for (      String key : requestParameters.keySet()) {
        writer.append(key);
        writer.append("String_Node_Str");
        writer.append(requestParameters.get(key).toString());
      }
    }
  finally {
      if (writer != null) {
        try {
          writer.close();
        }
 catch (        Exception e) {
        }
      }
      if (os != null) {
        try {
          os.close();
        }
 catch (        Exception e) {
        }
      }
    }
  }
  conn.connect();
  HttpResponse response=new HttpResponse();
  response.setStatusCode(conn.getResponseCode());
  response.setHeaders(conn.getHeaderFields());
  response.setContent(getResponseCotent(conn,charset));
  return response;
}
Program: 7597
Project: 7597
Buggy source:
@Test public void doRequest_A$String$HttpMethod$Map$String() throws Exception {
  String realm=null;
  OAuthConsumer consumer=new OAuthConsumer();
  SignatureMethod signatureMethod=SignatureMethod.HMAC_SHA1;
  SignedRequestImpl target=new SignedRequestImpl(realm,consumer,signatureMethod);
  String url="String_Node_Str";
  HttpMethod method=HttpMethod.GET;
  Map<String,Object> requestParameters=new HashMap<String,Object>();
  String charset="String_Node_Str";
  HttpResponse actual=target.doRequest(url,method,requestParameters,charset);
  assertNotNull(actual);
}

Fixed version (ground truth):
@Test public void doRequest_A$String$HttpMethod$Map$String() throws Exception {
  String realm=null;
  OAuthConsumer consumer=new OAuthConsumer();
  SignatureMethod signatureMethod=SignatureMethod.HMAC_SHA1;
  SignedRequestImpl target=new SignedRequestImpl(realm,consumer,signatureMethod);
  String url="String_Node_Str";
  HttpMethod method=HttpMethod.GET;
  Map<String,Object> requestParameters=new HashMap<String,Object>();
  requestParameters.put("String_Node_Str","String_Node_Str");
  String charset="String_Node_Str";
  HttpResponse actual=target.doRequest(url,method,requestParameters,charset);
  assertNotNull(actual);
}
Program: 7598
Project: 7598
Buggy source:
/** 
 * Prepare the destination file to receive data.  If the file already exists, we'll set up appropriately for resumption.
 */
private void setupDestinationFile(State state,InnerState innerState) throws StopRequest {
  if (state.mFilename != null) {
    if (!Helpers.isFilenameValid(state.mFilename)) {
      throw new StopRequest(Downloads.Impl.STATUS_FILE_ERROR,"String_Node_Str");
    }
    File f=new File(state.mFilename);
    if (f.exists()) {
      long fileLength=f.length();
      if (fileLength == 0) {
        f.delete();
        state.mFilename=null;
      }
 else       if (mInfo.mETag == null && !mInfo.mNoIntegrity) {
        f.delete();
        throw new StopRequest(Downloads.Impl.STATUS_CANNOT_RESUME,"String_Node_Str");
      }
 else {
        try {
          state.mStream=new FileOutputStream(state.mFilename,true);
        }
 catch (        FileNotFoundException exc) {
          throw new StopRequest(Downloads.Impl.STATUS_FILE_ERROR,"String_Node_Str" + exc.toString(),exc);
        }
        innerState.mBytesSoFar=(int)fileLength;
        if (mInfo.mTotalBytes != -1) {
          innerState.mHeaderContentLength=Long.toString(mInfo.mTotalBytes);
        }
        innerState.mHeaderETag=mInfo.mETag;
        innerState.mContinuingDownload=true;
      }
    }
  }
  if (state.mStream != null && mInfo.mDestination == Downloads.Impl.DESTINATION_EXTERNAL && !isDrmFile(state)) {
    closeDestination(state);
  }
}

Fixed version (ground truth):
/** 
 * Prepare the destination file to receive data.  If the file already exists, we'll set up appropriately for resumption.
 */
private void setupDestinationFile(State state,InnerState innerState) throws StopRequest {
  if (TextUtils.isEmpty(state.mFilename)) {
    if (!Helpers.isFilenameValid(state.mFilename)) {
      throw new StopRequest(Downloads.Impl.STATUS_FILE_ERROR,"String_Node_Str");
    }
    File f=new File(state.mFilename);
    if (f.exists()) {
      long fileLength=f.length();
      if (fileLength == 0) {
        f.delete();
        state.mFilename=null;
      }
 else       if (mInfo.mETag == null && !mInfo.mNoIntegrity) {
        f.delete();
        throw new StopRequest(Downloads.Impl.STATUS_CANNOT_RESUME,"String_Node_Str");
      }
 else {
        try {
          state.mStream=new FileOutputStream(state.mFilename,true);
        }
 catch (        FileNotFoundException exc) {
          throw new StopRequest(Downloads.Impl.STATUS_FILE_ERROR,"String_Node_Str" + exc.toString(),exc);
        }
        innerState.mBytesSoFar=(int)fileLength;
        if (mInfo.mTotalBytes != -1) {
          innerState.mHeaderContentLength=Long.toString(mInfo.mTotalBytes);
        }
        innerState.mHeaderETag=mInfo.mETag;
        innerState.mContinuingDownload=true;
      }
    }
  }
  if (state.mStream != null && mInfo.mDestination == Downloads.Impl.DESTINATION_EXTERNAL && !isDrmFile(state)) {
    closeDestination(state);
  }
}
Program: 7600
Project: 7600
Buggy source:
/** 
 * Prepare the destination file to receive data.  If the file already exists, we'll set up appropriately for resumption.
 */
private void setupDestinationFile(State state,InnerState innerState) throws StopRequest {
  if (state.mFilename != null) {
    if (!Helpers.isFilenameValid(state.mFilename)) {
      throw new StopRequest(Downloads.Impl.STATUS_FILE_ERROR,"String_Node_Str");
    }
    File f=new File(state.mFilename);
    if (f.exists()) {
      long fileLength=f.length();
      if (fileLength == 0) {
        f.delete();
        state.mFilename=null;
      }
 else       if (mInfo.mETag == null && !mInfo.mNoIntegrity) {
        f.delete();
        throw new StopRequest(Downloads.Impl.STATUS_CANNOT_RESUME,"String_Node_Str");
      }
 else {
        try {
          state.mStream=new FileOutputStream(state.mFilename,true);
        }
 catch (        FileNotFoundException exc) {
          throw new StopRequest(Downloads.Impl.STATUS_FILE_ERROR,"String_Node_Str" + exc.toString(),exc);
        }
        innerState.mBytesSoFar=(int)fileLength;
        if (mInfo.mTotalBytes != -1) {
          innerState.mHeaderContentLength=Long.toString(mInfo.mTotalBytes);
        }
        innerState.mHeaderETag=mInfo.mETag;
        innerState.mContinuingDownload=true;
      }
    }
  }
  if (state.mStream != null && mInfo.mDestination == Downloads.Impl.DESTINATION_EXTERNAL && !isDrmFile(state)) {
    closeDestination(state);
  }
}

Fixed version (ground truth):
/** 
 * Prepare the destination file to receive data.  If the file already exists, we'll set up appropriately for resumption.
 */
private void setupDestinationFile(State state,InnerState innerState) throws StopRequest {
  if (TextUtils.isEmpty(state.mFilename)) {
    if (!Helpers.isFilenameValid(state.mFilename)) {
      throw new StopRequest(Downloads.Impl.STATUS_FILE_ERROR,"String_Node_Str");
    }
    File f=new File(state.mFilename);
    if (f.exists()) {
      long fileLength=f.length();
      if (fileLength == 0) {
        f.delete();
        state.mFilename=null;
      }
 else       if (mInfo.mETag == null && !mInfo.mNoIntegrity) {
        f.delete();
        throw new StopRequest(Downloads.Impl.STATUS_CANNOT_RESUME,"String_Node_Str");
      }
 else {
        try {
          state.mStream=new FileOutputStream(state.mFilename,true);
        }
 catch (        FileNotFoundException exc) {
          throw new StopRequest(Downloads.Impl.STATUS_FILE_ERROR,"String_Node_Str" + exc.toString(),exc);
        }
        innerState.mBytesSoFar=(int)fileLength;
        if (mInfo.mTotalBytes != -1) {
          innerState.mHeaderContentLength=Long.toString(mInfo.mTotalBytes);
        }
        innerState.mHeaderETag=mInfo.mETag;
        innerState.mContinuingDownload=true;
      }
    }
  }
  if (state.mStream != null && mInfo.mDestination == Downloads.Impl.DESTINATION_EXTERNAL && !isDrmFile(state)) {
    closeDestination(state);
  }
}
Program: 7605
Project: 7605
Buggy source:
/** 
 * Close the destination output stream.
 */
private void closeDestination(State state){
  try {
    if (state.mStream != null) {
      state.mStream.close();
    }
  }
 catch (  IOException ex) {
    if (Constants.LOGV) {
      Log.v(Constants.TAG,"String_Node_Str" + ex);
    }
  }
}

Fixed version (ground truth):
/** 
 * Close the destination output stream.
 */
private void closeDestination(State state){
  try {
    if (state.mStream != null) {
      state.mStream.close();
      state.mStream=null;
    }
  }
 catch (  IOException ex) {
    if (Constants.LOGV) {
      Log.v(Constants.TAG,"String_Node_Str" + ex);
    }
  }
}
Program: 7606
Project: 7606
Buggy source:
/** 
 * Checks whether the filename looks legitimate
 */
public static boolean isFilenameValid(String filename){
  File dir=new File(filename).getParentFile();
  return dir.equals(Environment.getDownloadCacheDirectory()) || dir.equals(new File(Environment.getExternalStorageDirectory() + Constants.DEFAULT_DL_SUBDIR));
}

Fixed version (ground truth):
/** 
 * Checks whether the filename looks legitimate
 */
public static boolean isFilenameValid(String filename){
  filename=filename.replaceFirst("String_Node_Str","String_Node_Str");
  return filename.startsWith(Environment.getDownloadCacheDirectory().toString()) || filename.startsWith(Environment.getExternalStorageDirectory().toString());
}
Program: 7607
Project: 7607
Buggy source:
public void testDestination() throws Exception {
  enqueueResponse(HTTP_OK,FILE_CONTENT);
  Uri destination=Uri.fromFile(mTestDirectory).buildUpon().appendPath("String_Node_Str").build();
  Download download=enqueueRequest(getRequest().setDestinationUri(destination));
  download.runUntilStatus(DownloadManager.STATUS_SUCCESSFUL);
  Uri localUri=Uri.parse(download.getStringField(DownloadManager.COLUMN_LOCAL_URI));
  assertEquals(destination,localUri);
  InputStream stream=new FileInputStream(destination.getSchemeSpecificPart());
  try {
    assertEquals(FILE_CONTENT,readStream(stream));
  }
  finally {
    stream.close();
  }
}

Fixed version (ground truth):
public void testDestination() throws Exception {
  enqueueResponse(HTTP_OK,FILE_CONTENT);
  Uri destination=getExternalUri();
  Download download=enqueueRequest(getRequest().setDestinationUri(destination));
  download.runUntilStatus(DownloadManager.STATUS_SUCCESSFUL);
  Uri localUri=Uri.parse(download.getStringField(DownloadManager.COLUMN_LOCAL_URI));
  assertEquals(destination,localUri);
  InputStream stream=new FileInputStream(destination.getSchemeSpecificPart());
  try {
    assertEquals(FILE_CONTENT,readStream(stream));
  }
  finally {
    stream.close();
  }
}
Program: 7608
Project: 7608
Buggy source:
private void readRequestHeaders(long downloadId){
  Uri headerUri=Uri.withAppendedPath(getAllDownloadsUri(),Downloads.Impl.RequestHeaders.URI_SEGMENT);
  Cursor cursor=mContext.getContentResolver().query(headerUri,null,null,null,null);
  try {
    int headerIndex=cursor.getColumnIndexOrThrow(Downloads.Impl.RequestHeaders.COLUMN_HEADER);
    int valueIndex=cursor.getColumnIndexOrThrow(Downloads.Impl.RequestHeaders.COLUMN_VALUE);
    for (cursor.moveToFirst(); !cursor.isAfterLast(); cursor.moveToNext()) {
      mRequestHeaders.put(cursor.getString(headerIndex),cursor.getString(valueIndex));
    }
  }
  finally {
    cursor.close();
  }
  if (mCookies != null) {
    mRequestHeaders.put("String_Node_Str",mCookies);
  }
  if (mReferer != null) {
    mRequestHeaders.put("String_Node_Str",mReferer);
  }
}

Fixed version (ground truth):
private void readRequestHeaders(DownloadInfo info){
  info.mRequestHeaders.clear();
  Uri headerUri=Uri.withAppendedPath(info.getAllDownloadsUri(),Downloads.Impl.RequestHeaders.URI_SEGMENT);
  Cursor cursor=mResolver.query(headerUri,null,null,null,null);
  try {
    int headerIndex=cursor.getColumnIndexOrThrow(Downloads.Impl.RequestHeaders.COLUMN_HEADER);
    int valueIndex=cursor.getColumnIndexOrThrow(Downloads.Impl.RequestHeaders.COLUMN_VALUE);
    for (cursor.moveToFirst(); !cursor.isAfterLast(); cursor.moveToNext()) {
      info.mRequestHeaders.put(cursor.getString(headerIndex),cursor.getString(valueIndex));
    }
  }
  finally {
    cursor.close();
  }
  if (info.mCookies != null) {
    info.mRequestHeaders.put("String_Node_Str",info.mCookies);
  }
  if (info.mReferer != null) {
    info.mRequestHeaders.put("String_Node_Str",info.mReferer);
  }
}
Program: 7609
Project: 7609
Buggy source:
public void sendIntentIfRequested(){
  if (mPackage == null) {
    return;
  }
  Intent intent;
  if (mIsPublicApi) {
    intent=new Intent(DownloadManager.ACTION_DOWNLOAD_COMPLETE);
    intent.setPackage(mPackage);
    intent.putExtra(DownloadManager.EXTRA_DOWNLOAD_ID,(long)mId);
  }
 else {
    if (mClass == null) {
      return;
    }
    intent=new Intent(Downloads.Impl.ACTION_DOWNLOAD_COMPLETED);
    intent.setClassName(mPackage,mClass);
    if (mExtras != null) {
      intent.putExtra(Downloads.Impl.COLUMN_NOTIFICATION_EXTRAS,mExtras);
    }
    intent.setData(getMyDownloadsUri());
  }
  mSystemFacade.sendBroadcast(intent);
}

Fixed version (ground truth):
public void sendIntentIfRequested(){
  if (mPackage == null) {
    return;
  }
  Intent intent;
  if (mIsPublicApi) {
    intent=new Intent(DownloadManager.ACTION_DOWNLOAD_COMPLETE);
    intent.setPackage(mPackage);
    intent.putExtra(DownloadManager.EXTRA_DOWNLOAD_ID,mId);
  }
 else {
    if (mClass == null) {
      return;
    }
    intent=new Intent(Downloads.Impl.ACTION_DOWNLOAD_COMPLETED);
    intent.setClassName(mPackage,mClass);
    if (mExtras != null) {
      intent.putExtra(Downloads.Impl.COLUMN_NOTIFICATION_EXTRAS,mExtras);
    }
    intent.setData(getMyDownloadsUri());
  }
  mSystemFacade.sendBroadcast(intent);
}