nus-yam/ex-repair huggingface dataset:
Program: 25995
Project: 25995
Buggy source:
/** 
 * Fetches all Organizations (including a minimal set of information on the contained workspaces) that are available to the user.
 * @param providerListener The callback implementation called when the items are fetched. Null is valid, but doesn't make any sense.
 * @return A ticket which the caller can use to identify this requestwith.
 */
public static final Object getAll(PodioProviderListener providerListener){
  ItemParser<com.podio.sdk.domain.Organization[]> parser=new ItemParser<com.podio.sdk.domain.Organization[]>(com.podio.sdk.domain.Organization[].class);
  client.setItemParser(parser);
  OrganizationProvider provider=new OrganizationProvider();
  provider.setRestClient(client);
  provider.setProviderListener(providerListener);
  return provider.getAll();
}

Fixed version (ground truth):
/** 
 * Fetches all Organizations (including a minimal set of information on the contained workspaces) that are available to the user.
 * @param providerListener The callback implementation called when the items are fetched. Null is valid, but doesn't make any sense.
 * @return A ticket which the caller can use to identify this requestwith.
 */
public static final Object getAll(PodioProviderListener providerListener){
  ItemParser<com.podio.sdk.domain.Organization[]> parser=new ItemParser<com.podio.sdk.domain.Organization[]>(com.podio.sdk.domain.Organization[].class);
  OrganizationProvider provider=new OrganizationProvider();
  provider.setRestClient(client);
  provider.setProviderListener(providerListener);
  provider.setItemParser(parser);
  return provider.getAll();
}
Program: 25996
Project: 25996
Buggy source:
/** 
 * Fetches all App items, including the inactive ones, in the workspace with the given id.
 * @param spaceId The id of the parent workspace.
 * @param providerListener The callback implementation called when the items are fetched. Null is valid, but doesn't make any sense.
 * @return A ticket which the caller can use to identify this requestwith.
 */
public static final Object getForSpaceIncludingInactive(long spaceId,PodioProviderListener providerListener){
  ItemParser<com.podio.sdk.domain.Application[]> parser=new ItemParser<com.podio.sdk.domain.Application[]>(com.podio.sdk.domain.Application[].class);
  client.setItemParser(parser);
  ApplicationProvider provider=new ApplicationProvider();
  provider.setRestClient(client);
  provider.setProviderListener(providerListener);
  return provider.fetchApplicationsForSpaceWithInactivesIncluded(spaceId);
}

Fixed version (ground truth):
/** 
 * Fetches all App items, including the inactive ones, in the workspace with the given id.
 * @param spaceId The id of the parent workspace.
 * @param providerListener The callback implementation called when the items are fetched. Null is valid, but doesn't make any sense.
 * @return A ticket which the caller can use to identify this requestwith.
 */
public static final Object getForSpaceIncludingInactive(long spaceId,PodioProviderListener providerListener){
  ItemParser<com.podio.sdk.domain.Application[]> parser=new ItemParser<com.podio.sdk.domain.Application[]>(com.podio.sdk.domain.Application[].class);
  ApplicationProvider provider=new ApplicationProvider();
  provider.setRestClient(client);
  provider.setProviderListener(providerListener);
  provider.setItemParser(parser);
  return provider.fetchApplicationsForSpaceWithInactivesIncluded(spaceId);
}
Program: 25997
Project: 25997
Buggy source:
/** 
 * Fetches all App items in the workspace with the given id.
 * @param spaceId The id of the parent workspace.
 * @param providerListener The callback implementation called when the items are fetched. Null is valid, but doesn't make any sense.
 * @return A ticket which the caller can use to identify this requestwith.
 */
public static final Object getForSpace(long spaceId,PodioProviderListener providerListener){
  ItemParser<com.podio.sdk.domain.Application[]> parser=new ItemParser<com.podio.sdk.domain.Application[]>(com.podio.sdk.domain.Application[].class);
  client.setItemParser(parser);
  ApplicationProvider provider=new ApplicationProvider();
  provider.setRestClient(client);
  provider.setProviderListener(providerListener);
  return provider.fetchApplicationsForSpace(spaceId);
}

Fixed version (ground truth):
/** 
 * Fetches all App items in the workspace with the given id.
 * @param spaceId The id of the parent workspace.
 * @param providerListener The callback implementation called when the items are fetched. Null is valid, but doesn't make any sense.
 * @return A ticket which the caller can use to identify this requestwith.
 */
public static final Object getForSpace(long spaceId,PodioProviderListener providerListener){
  ItemParser<com.podio.sdk.domain.Application[]> parser=new ItemParser<com.podio.sdk.domain.Application[]>(com.podio.sdk.domain.Application[].class);
  ApplicationProvider provider=new ApplicationProvider();
  provider.setRestClient(client);
  provider.setProviderListener(providerListener);
  provider.setItemParser(parser);
  return provider.fetchApplicationsForSpace(spaceId);
}
Program: 25998
Project: 25998
Buggy source:
/** 
 * Authenticates the caller with the given app credentials. On success a new session object with the access and refresh tokens will be delivered through the given   {@link PodioProviderListener}.
 * @param appId The id of the app to authenticate with.
 * @param appToken The token that has been generated for a particular app.
 * @param providerListener The callback implementation called when the items are fetched. Null is valid, but doesn't make any sense.
 * @return A ticket which the caller can use to identify this requestwith.
 */
public static final Object authenticateAsApp(String appId,String appToken,PodioProviderListener providerListener){
  ItemParser<com.podio.sdk.domain.Session> parser=new ItemParser<com.podio.sdk.domain.Session>(com.podio.sdk.domain.Session.class);
  client.setItemParser(parser);
  SessionProvider provider=new SessionProvider();
  provider.setRestClient(client);
  provider.setProviderListener(providerListener);
  return provider.authenticateWithAppCredentials(clientId,clientSecret,appId,appToken);
}

Fixed version (ground truth):
/** 
 * Authenticates the caller with the given app credentials. On success a new session object with the access and refresh tokens will be delivered through the given   {@link PodioProviderListener}.
 * @param appId The id of the app to authenticate with.
 * @param appToken The token that has been generated for a particular app.
 * @param providerListener The callback implementation called when the items are fetched. Null is valid, but doesn't make any sense.
 * @return A ticket which the caller can use to identify this requestwith.
 */
public static final Object authenticateAsApp(String appId,String appToken,PodioProviderListener providerListener){
  ItemParser<com.podio.sdk.domain.Session> parser=new ItemParser<com.podio.sdk.domain.Session>(com.podio.sdk.domain.Session.class);
  SessionProvider provider=new SessionProvider();
  provider.setRestClient(client);
  provider.setProviderListener(providerListener);
  provider.setItemParser(parser);
  return provider.authenticateWithAppCredentials(clientId,clientSecret,appId,appToken);
}
Program: 25999
Project: 25999
Buggy source:
/** 
 * Authenticates the caller with the given user credentials. On success a new session object with the access and refresh tokens will be delivered through the given   {@link PodioProviderListener}.
 * @param username The user name of the Podio account to authenticate with.
 * @param password The corresponding password of the Podio account.
 * @param providerListener The callback implementation called when the items are fetched. Null is valid, but doesn't make any sense.
 * @return A ticket which the caller can use to identify this requestwith.
 */
public static final Object authenticateAsUser(String username,String password,PodioProviderListener providerListener){
  ItemParser<com.podio.sdk.domain.Session> parser=new ItemParser<com.podio.sdk.domain.Session>(com.podio.sdk.domain.Session.class);
  client.setItemParser(parser);
  SessionProvider provider=new SessionProvider();
  provider.setRestClient(client);
  provider.setProviderListener(providerListener);
  return provider.authenticateWithUserCredentials(clientId,clientSecret,username,password);
}

Fixed version (ground truth):
/** 
 * Authenticates the caller with the given user credentials. On success a new session object with the access and refresh tokens will be delivered through the given   {@link PodioProviderListener}.
 * @param username The user name of the Podio account to authenticate with.
 * @param password The corresponding password of the Podio account.
 * @param providerListener The callback implementation called when the items are fetched. Null is valid, but doesn't make any sense.
 * @return A ticket which the caller can use to identify this requestwith.
 */
public static final Object authenticateAsUser(String username,String password,PodioProviderListener providerListener){
  ItemParser<com.podio.sdk.domain.Session> parser=new ItemParser<com.podio.sdk.domain.Session>(com.podio.sdk.domain.Session.class);
  SessionProvider provider=new SessionProvider();
  provider.setRestClient(client);
  provider.setProviderListener(providerListener);
  provider.setItemParser(parser);
  return provider.authenticateWithUserCredentials(clientId,clientSecret,username,password);
}
Program: 26000
Project: 26000
Buggy source:
/** 
 * Fetches a default set of filtered items for the application with the given id.
 * @param applicationId The id of the parent application.
 * @param providerListener The callback implementation called when the items are fetched. Null is valid, but doesn't make any sense.
 * @return A ticket which the caller can use to identify this requestwith.
 */
public static final Object getForApplication(long applicationId,PodioProviderListener providerListener){
  ItemParser<com.podio.sdk.domain.ItemRequest.Result> parser=new ItemParser<com.podio.sdk.domain.ItemRequest.Result>(com.podio.sdk.domain.ItemRequest.Result.class);
  client.setItemParser(parser);
  ItemProvider provider=new ItemProvider();
  provider.setRestClient(client);
  provider.setProviderListener(providerListener);
  return provider.fetchItemsForApplication(applicationId);
}

Fixed version (ground truth):
/** 
 * Fetches a default set of filtered items for the application with the given id.
 * @param applicationId The id of the parent application.
 * @param providerListener The callback implementation called when the items are fetched. Null is valid, but doesn't make any sense.
 * @return A ticket which the caller can use to identify this requestwith.
 */
public static final Object getForApplication(long applicationId,PodioProviderListener providerListener){
  ItemParser<com.podio.sdk.domain.ItemRequest.Result> parser=new ItemParser<com.podio.sdk.domain.ItemRequest.Result>(com.podio.sdk.domain.ItemRequest.Result.class);
  ItemProvider provider=new ItemProvider();
  provider.setRestClient(client);
  provider.setProviderListener(providerListener);
  provider.setItemParser(parser);
  return provider.fetchItemsForApplication(applicationId);
}
Program: 26001
Project: 26001
Buggy source:
/** 
 * Fetches a single item with the given id.
 * @param itemId The id of the item to fetch.
 * @param providerListener The callback implementation called when the items are fetched. Null is valid, but doesn't make any sense.
 * @return A ticket which the caller can use to identify this requestwith.
 */
public static final Object get(long itemId,PodioProviderListener providerListener){
  ItemParser<com.podio.sdk.domain.Item> parser=new ItemParser<com.podio.sdk.domain.Item>(com.podio.sdk.domain.Item.class);
  client.setItemParser(parser);
  ItemProvider provider=new ItemProvider();
  provider.setRestClient(client);
  provider.setProviderListener(providerListener);
  return provider.fetchItem(itemId);
}

Fixed version (ground truth):
/** 
 * Fetches a single item with the given id.
 * @param itemId The id of the item to fetch.
 * @param providerListener The callback implementation called when the items are fetched. Null is valid, but doesn't make any sense.
 * @return A ticket which the caller can use to identify this requestwith.
 */
public static final Object get(long itemId,PodioProviderListener providerListener){
  ItemParser<com.podio.sdk.domain.Item> parser=new ItemParser<com.podio.sdk.domain.Item>(com.podio.sdk.domain.Item.class);
  ItemProvider provider=new ItemProvider();
  provider.setRestClient(client);
  provider.setProviderListener(providerListener);
  provider.setItemParser(parser);
  return provider.fetchItem(itemId);
}
Program: 26002
Project: 26002
Buggy source:
/** 
 * Revokes a previously created Podio session. Even though the access token may have expired, the refresh token can be used to get a new access token. The idea here is to enable the caller to persist the session and avoid an unnecessary re-authentication. NOTE! The server may very well invalidate both the access and refresh tokens, which would require a re-authentication anyway.
 * @param session The previously stored session object.
 */
public static final void restoreSession(Session session){
  client.setItemParser(null);
  client.restoreSession(SessionFilter.PATH,session);
}

Fixed version (ground truth):
/** 
 * Revokes a previously created Podio session. Even though the access token may have expired, the refresh token can be used to get a new access token. The idea here is to enable the caller to persist the session and avoid an unnecessary re-authentication. NOTE! The server may very well invalidate both the access and refresh tokens, which would require a re-authentication anyway.
 * @param session The previously stored session object.
 */
public static final void restoreSession(Session session){
  client.restoreSession(SessionFilter.PATH,session);
}
Program: 26003
Project: 26003
Buggy source:
public RestResult post(Uri uri,Object item);

Fixed version (ground truth):
public RestResult post(Uri uri,Object item,ItemParser<?> parser);
Program: 26004
Project: 26004
Buggy source:
public RestResult get(Uri uri);

Fixed version (ground truth):
public RestResult get(Uri uri,ItemParser<?> parser);
Program: 26005
Project: 26005
Buggy source:
public RestResult authorize(Uri uri);

Fixed version (ground truth):
public RestResult authorize(Uri uri,ItemParser<?> parser);
Program: 26006
Project: 26006
Buggy source:
public RestResult delete(Uri uri);

Fixed version (ground truth):
public RestResult delete(Uri uri,ItemParser<?> parser);
Program: 26007
Project: 26007
Buggy source:
public RestResult put(Uri uri,Object item);

Fixed version (ground truth):
public RestResult put(Uri uri,Object item,ItemParser<?> parser);
Program: 26008
Project: 26008
Buggy source:
/** 
 * Lets the assigned   {@link RestClientDelegate} implementation act upon theunderlying content as requested per operation and Uri.
 * @param operation The operation to perform.
 * @param uri The key used to identify the content.
 * @param item The description of the new content.
 * @return The result description of the requested operation.
 */
private RestResult delegate(RestOperation operation,Uri uri,Object item){
switch (operation) {
case DELETE:
    return databaseDelegate.delete(uri);
case GET:
  return databaseDelegate.get(uri);
case POST:
return databaseDelegate.post(uri,item);
case PUT:
return databaseDelegate.put(uri,item);
default :
String message="String_Node_Str" + operation.name();
return new RestResult(false,message,null);
}
}

Fixed version (ground truth):
/** 
 * Lets the assigned   {@link RestClientDelegate} implementation act upon theunderlying content as requested per operation and Uri.
 * @param operation The operation to perform.
 * @param uri The key used to identify the content.
 * @param item The description of the new content.
 * @return The result description of the requested operation.
 */
private RestResult delegate(RestOperation operation,Uri uri,Object item,ItemParser<?> itemParser){
switch (operation) {
case DELETE:
    return databaseDelegate.delete(uri,itemParser);
case GET:
  return databaseDelegate.get(uri,itemParser);
case POST:
return databaseDelegate.post(uri,item,itemParser);
case PUT:
return databaseDelegate.put(uri,item,itemParser);
default :
String message="String_Node_Str" + operation.name();
return new RestResult(false,message,null);
}
}
Program: 26010
Project: 26010
Buggy source:
/** 
 * {@inheritDoc}
 */
@Override protected RestResult handleRequest(RestRequest restRequest){
  RestResult result=null;
  if (restRequest != null) {
    PodioFilter filter=restRequest.getFilter();
    if (filter != null) {
      RestOperation operation=restRequest.getOperation();
      Object item=restRequest.getContent();
      Uri uri=filter.buildUri(scheme,authority);
      result=queryNetwork(operation,uri,item);
    }
  }
  return result != null ? result : new RestResult(false,null,null);
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 */
@Override protected RestResult handleRequest(RestRequest restRequest){
  RestResult result=null;
  if (restRequest != null) {
    PodioFilter filter=restRequest.getFilter();
    if (filter != null) {
      Uri uri=filter.buildUri(scheme,authority);
      RestOperation operation=restRequest.getOperation();
      Object item=restRequest.getContent();
      ItemParser<?> parser=restRequest.getItemParser();
      result=queryNetwork(operation,uri,item,parser);
    }
  }
  return result != null ? result : new RestResult(false,null,null);
}
Program: 26011
Project: 26011
Buggy source:
private RestResult queryNetwork(RestOperation operation,Uri uri,Object item){
switch (operation) {
case AUTHORIZE:
    return networkDelegate.authorize(uri);
case DELETE:
  return networkDelegate.delete(uri);
case GET:
return networkDelegate.get(uri);
case POST:
return networkDelegate.post(uri,item);
case PUT:
return networkDelegate.put(uri,item);
default :
String message="String_Node_Str" + operation.name();
return new RestResult(false,message,null);
}
}

Fixed version (ground truth):
private RestResult queryNetwork(RestOperation operation,Uri uri,Object item,ItemParser<?> parser){
switch (operation) {
case AUTHORIZE:
    return networkDelegate.authorize(uri,parser);
case DELETE:
  return networkDelegate.delete(uri,parser);
case GET:
return networkDelegate.get(uri,parser);
case POST:
return networkDelegate.post(uri,item,parser);
case PUT:
return networkDelegate.put(uri,item,parser);
default :
String message="String_Node_Str" + operation.name();
return new RestResult(false,message,null);
}
}
Program: 26012
Project: 26012
Buggy source:
/** 
 * Delegates the requested operation to the   {@link DatabaseClientDelegate}to execute.
 * @param operation The type of rest operation to perform.
 * @param uri The URI that defines the details of the operation.
 * @param content Any additional data that the operation refers to.
 * @return An object representation of the result of the operation.
 */
private RestResult queryDatabase(RestOperation operation,Uri uri,Object content){
switch (operation) {
case AUTHORIZE:
    return databaseDelegate.authorize(uri);
case DELETE:
  return databaseDelegate.delete(uri);
case GET:
return databaseDelegate.get(uri);
case POST:
return databaseDelegate.post(uri,content);
case PUT:
return databaseDelegate.put(uri,content);
default :
String message="String_Node_Str" + operation.name();
return new RestResult(false,message,null);
}
}

Fixed version (ground truth):
/** 
 * Delegates the requested operation to the   {@link DatabaseClientDelegate}to execute.
 * @param operation The type of rest operation to perform.
 * @param uri The URI that defines the details of the operation.
 * @param content Any additional data that the operation refers to.
 * @return An object representation of the result of the operation.
 */
private RestResult queryDatabase(RestOperation operation,Uri uri,Object content,ItemParser<?> itemParser){
switch (operation) {
case AUTHORIZE:
    return databaseDelegate.authorize(uri,itemParser);
case DELETE:
  return databaseDelegate.delete(uri,itemParser);
case GET:
return databaseDelegate.get(uri,itemParser);
case POST:
return databaseDelegate.post(uri,content,itemParser);
case PUT:
return databaseDelegate.put(uri,content,itemParser);
default :
String message="String_Node_Str" + operation.name();
return new RestResult(false,message,null);
}
}
Program: 26013
Project: 26013
Buggy source:
/** 
 * {@inheritDoc}
 */
@Override protected RestResult handleRequest(RestRequest restRequest){
  RestResult result=null;
  if (restRequest != null) {
    PodioFilter filter=restRequest.getFilter();
    if (filter != null) {
      RestOperation operation=restRequest.getOperation();
      Object item=restRequest.getContent();
      Uri uri=filter.buildUri(scheme,authority);
      result=queryDatabase(operation,uri,item);
    }
  }
  return result;
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 */
@Override protected RestResult handleRequest(RestRequest restRequest){
  RestResult result=null;
  if (restRequest != null) {
    PodioFilter filter=restRequest.getFilter();
    ItemParser<?> itemParser=restRequest.getItemParser();
    if (filter != null) {
      RestOperation operation=restRequest.getOperation();
      Object item=restRequest.getContent();
      Uri uri=filter.buildUri(scheme,authority);
      result=queryDatabase(operation,uri,item,itemParser);
    }
  }
  return result;
}
Program: 26014
Project: 26014
Buggy source:
public Object fetchItemsForApplication(long applicationId){
  PodioParser<Item> parser=new PodioParser<Item>(Item.class);
  ItemFilter filter=new ItemFilter().withApplicationId(applicationId);
  ItemRequest filterRequest=new ItemRequest(null,null,null,null,null,null);
  return pushRequest(filter,filterRequest,parser);
}

Fixed version (ground truth):
public Object fetchItemsForApplication(long applicationId){
  PodioParser<ItemRequest.Result> parser=new PodioParser<ItemRequest.Result>(ItemRequest.Result.class);
  ItemFilter filter=new ItemFilter().withApplicationId(applicationId);
  ItemRequest filterRequest=new ItemRequest(null,null,null,null,null,null);
  return pushRequest(filter,filterRequest,parser);
}
Program: 26015
Project: 26015
Buggy source:
@Override public RestResult get(Uri uri,Class<?> classOfResult){
  String json=null;
  SQLiteDatabase database=openDatabase(uri);
  if (database != null) {
    String[] projection={"String_Node_Str"};
    String key="String_Node_Str";
    String[] value={uri.toString()};
    Cursor cursor=database.query("String_Node_Str",projection,key,value,null,null,null);
    if (cursor != null) {
      json=cursor.moveToFirst() ? cursor.getString(0) : "String_Node_Str";
    }
  }
  boolean isSuccess=json != null;
  String message=null;
  Object item=jsonToItemParser.parse(json,classOfResult);
  RestResult result=new RestResult(isSuccess,message,item);
  return result;
}

Fixed version (ground truth):
@Override public RestResult get(Uri uri,Class<?> classOfResult){
  String json=null;
  SQLiteDatabase database=openDatabase(uri);
  if (database != null) {
    String[] projection={"String_Node_Str"};
    String key="String_Node_Str";
    String[] value={uri.toString()};
    Cursor cursor=database.query("String_Node_Str",projection,key,value,null,null,null);
    if (cursor != null) {
      json=cursor.moveToFirst() ? cursor.getString(0) : null;
    }
  }
  boolean isSuccess=json != null;
  String message=null;
  Object item=jsonToItemParser.parse(json,classOfResult);
  RestResult result=new RestResult(isSuccess,message,item);
  return result;
}
Program: 26017
Project: 26017
Buggy source:
@Override public RestResult get(Uri uri) throws InvalidParserException {
  ItemParser.raiseExceptionIfInvalidInstance(itemParser);
  String json=null;
  SQLiteDatabase database=openDatabase(uri);
  if (database != null) {
    String[] projection={"String_Node_Str"};
    String key="String_Node_Str";
    String[] value={uri.toString()};
    Cursor cursor=database.query("String_Node_Str",projection,key,value,null,null,null);
    if (cursor != null) {
      json=cursor.moveToFirst() ? cursor.getString(0) : null;
    }
  }
  boolean isSuccess=json != null;
  String message=null;
  Object item=itemParser.parseToItem(json);
  RestResult result=new RestResult(isSuccess,message,item);
  return result;
}

Fixed version (ground truth):
@Override public RestResult get(Uri uri) throws InvalidParserException {
  ItemParser.raiseExceptionIfInvalidInstance(itemParser);
  String json=null;
  SQLiteDatabase database=openDatabase(uri);
  if (database != null) {
    String[] projection={"String_Node_Str"};
    String key="String_Node_Str";
    String[] value={uri.toString()};
    Cursor cursor=database.query("String_Node_Str",projection,key,value,null,null,null);
    if (cursor != null) {
      json=cursor.moveToFirst() ? cursor.getString(0) : "String_Node_Str";
    }
  }
  boolean isSuccess=json != null;
  String message=null;
  Object item=itemParser.parseToItem(json);
  RestResult result=new RestResult(isSuccess,message,item);
  return result;
}
Program: 26018
Project: 26018
Buggy source:
private String request(int method,Uri uri,String body){
  String url=Utils.notEmpty(uri) ? uri.toString() : null;
  RequestFuture<String> future=RequestFuture.newFuture();
  StringRequest request=new PodioRequest(method,url,body,session,future);
  requestQueue.add(request);
  String result=getBlockingResponse(future);
  if (result == null && lastRequestError != null && lastRequestError.networkResponse != null) {
    if (lastRequestError.networkResponse.statusCode == 401) {
      session=new Session(null);
      refreshSession();
      future=RequestFuture.newFuture();
      request=new PodioRequest(method,url,body,session,future);
      requestQueue.add(request);
      result=getBlockingResponse(future);
    }
  }
  return result;
}

Fixed version (ground truth):
private String request(int method,Uri uri,String body){
  String url=Utils.notEmpty(uri) ? uri.toString() : null;
  String accessToken=session != null ? session.accessToken : "String_Node_Str";
  Map<String,String> headers=new HashMap<String,String>();
  headers.put("String_Node_Str","String_Node_Str" + accessToken);
  RequestFuture<String> future=RequestFuture.newFuture();
  StringRequest request=new PodioRequest(method,url,body,headers,future);
  requestQueue.add(request);
  String result=getBlockingResponse(future);
  return result;
}
Program: 26019
Project: 26019
Buggy source:
@Override public RestResult delete(Uri uri){
  Session resultSession=null;
  if (session.shouldRefreshTokens()) {
    refreshSession();
    resultSession=session;
  }
  String outputJson=request(Method.DELETE,uri,null);
  boolean isSuccess=Utils.notEmpty(outputJson);
  RestResult result=new RestResult(isSuccess,resultSession,null,null);
  return result;
}

Fixed version (ground truth):
@Override public RestResult delete(Uri uri){
  Session resultSession=null;
  if (session.shouldRefreshTokens()) {
    refreshSession();
    resultSession=session;
  }
  String outputJson=request(Method.DELETE,uri,null);
  if (outputJson == null && lastRequestError != null && lastRequestError.networkResponse != null && lastRequestError.networkResponse.statusCode == 401) {
    refreshSession();
    resultSession=session;
    outputJson=request(Method.DELETE,uri,null);
  }
  boolean isSuccess=Utils.notEmpty(outputJson);
  RestResult result=new RestResult(isSuccess,resultSession,null,null);
  return result;
}
Program: 26020
Project: 26020
Buggy source:
@Override public RestResult put(Uri uri,Object item,Class<?> classOfItem){
  Session resultSession=null;
  if (session.shouldRefreshTokens()) {
    refreshSession();
    resultSession=session;
  }
  String inputJson=itemToJsonParser.parse(item,classOfItem);
  String outputJson=request(Method.PUT,uri,inputJson);
  boolean isSuccess=Utils.notEmpty(outputJson);
  Object content=jsonToItemParser.parse(outputJson,classOfItem);
  RestResult result=new RestResult(isSuccess,resultSession,null,content);
  return result;
}

Fixed version (ground truth):
@Override public RestResult put(Uri uri,Object item,Class<?> classOfItem){
  Session resultSession=null;
  if (session.shouldRefreshTokens()) {
    refreshSession();
    resultSession=session;
  }
  String inputJson=itemToJsonParser.parse(item,classOfItem);
  String outputJson=request(Method.PUT,uri,inputJson);
  if (outputJson == null && lastRequestError != null && lastRequestError.networkResponse != null && lastRequestError.networkResponse.statusCode == 401) {
    refreshSession();
    resultSession=session;
    outputJson=request(Method.PUT,uri,inputJson);
  }
  boolean isSuccess=Utils.notEmpty(outputJson);
  Object content=jsonToItemParser.parse(outputJson,classOfItem);
  RestResult result=new RestResult(isSuccess,resultSession,null,content);
  return result;
}
Program: 26021
Project: 26021
Buggy source:
@Override public RestResult post(Uri uri,Object item,Class<?> classOfItem){
  Session resultSession=null;
  if (session.shouldRefreshTokens()) {
    refreshSession();
    resultSession=session;
  }
  String inputJson=itemToJsonParser.parse(item,classOfItem);
  String outputJson=request(Method.POST,uri,inputJson);
  boolean isSuccess=Utils.notEmpty(outputJson);
  Object content=jsonToItemParser.parse(outputJson,classOfItem);
  RestResult result=new RestResult(isSuccess,resultSession,null,content);
  return result;
}

Fixed version (ground truth):
@Override public RestResult post(Uri uri,Object item,Class<?> classOfItem){
  Session resultSession=null;
  if (session.shouldRefreshTokens()) {
    refreshSession();
    resultSession=session;
  }
  String inputJson=itemToJsonParser.parse(item,classOfItem);
  String outputJson=request(Method.POST,uri,inputJson);
  if (outputJson == null && lastRequestError != null && lastRequestError.networkResponse != null && lastRequestError.networkResponse.statusCode == 401) {
    refreshSession();
    resultSession=session;
    outputJson=request(Method.POST,uri,inputJson);
  }
  boolean isSuccess=Utils.notEmpty(outputJson);
  Object content=jsonToItemParser.parse(outputJson,classOfItem);
  RestResult result=new RestResult(isSuccess,resultSession,null,content);
  return result;
}
Program: 26022
Project: 26022
Buggy source:
@Override public RestResult get(Uri uri,Class<?> classOfResult){
  Session resultSession=null;
  if (session.shouldRefreshTokens()) {
    refreshSession();
    resultSession=session;
  }
  String outputJson=request(Method.GET,uri,null);
  boolean isSuccess=Utils.notEmpty(outputJson);
  Object item=jsonToItemParser.parse(outputJson,classOfResult);
  RestResult result=new RestResult(isSuccess,resultSession,null,item);
  return result;
}

Fixed version (ground truth):
@Override public RestResult get(Uri uri,Class<?> classOfResult){
  Session resultSession=null;
  if (session.shouldRefreshTokens()) {
    refreshSession();
    resultSession=session;
  }
  String outputJson=request(Method.GET,uri,null);
  if (outputJson == null && lastRequestError != null && lastRequestError.networkResponse != null && lastRequestError.networkResponse.statusCode == 401) {
    refreshSession();
    resultSession=session;
    outputJson=request(Method.GET,uri,null);
  }
  boolean isSuccess=Utils.notEmpty(outputJson);
  Object item=jsonToItemParser.parse(outputJson,classOfResult);
  RestResult result=new RestResult(isSuccess,resultSession,null,item);
  return result;
}
Program: 26023
Project: 26023
Buggy source:
@Override public Map<String,String> getHeaders() throws AuthFailureError {
  Map<String,String> headers=new HashMap<String,String>();
  if (Utils.notEmpty(authToken)) {
    headers.put("String_Node_Str","String_Node_Str" + authToken);
  }
  return headers;
}

Fixed version (ground truth):
@Override public Map<String,String> getHeaders() throws AuthFailureError {
  return headers;
}
Program: 26024
Project: 26024
Buggy source:
public PodioRequest(int method,String url,String body,Session session,RequestFuture<String> future){
  super(method,url,future,future);
  setShouldCache(false);
  this.authToken=session != null ? session.accessToken : "String_Node_Str";
  this.body=body;
}

Fixed version (ground truth):
public PodioRequest(int method,String url,String body,Map<String,String> headers,RequestFuture<String> future){
  super(method,url,future,future);
  setShouldCache(false);
  this.headers=headers;
  this.body=body;
}
Program: 26025
Project: 26025
Buggy source:
@Override public RestResult post(Uri uri,Object item) throws SQLiteException, InvalidParserException {
  long id=-1L;
  SQLiteDatabase database=sqliteHelper.getWritableDatabase();
  if (database != null) {
    String json=parseItem(item);
    ContentValues values=new ContentValues();
    values.put("String_Node_Str",uri.toString());
    values.put("String_Node_Str",json);
    id=database.insertWithOnConflict("String_Node_Str",null,values,SQLiteDatabase.CONFLICT_REPLACE);
  }
  boolean isSuccess=id != -1L;
  String message=null;
  List<?> items=null;
  RestResult result=new RestResult(isSuccess,message,items);
  return result;
}

Fixed version (ground truth):
@Override public RestResult post(Uri uri,Object item) throws SQLiteException, InvalidParserException {
  long id=-1L;
  if (Utils.notEmpty(uri)) {
    SQLiteDatabase database=sqliteHelper.getWritableDatabase();
    String json=parseItem(item);
    ContentValues values=new ContentValues();
    values.put("String_Node_Str",uri.toString());
    values.put("String_Node_Str",json);
    id=database.insertWithOnConflict("String_Node_Str",null,values,SQLiteDatabase.CONFLICT_REPLACE);
  }
  boolean isSuccess=id != -1L;
  String message=null;
  List<?> items=null;
  RestResult result=new RestResult(isSuccess,message,items);
  return result;
}
Program: 26026
Project: 26026
Buggy source:
@Override public RestResult get(Uri uri) throws SQLiteException, InvalidParserException {
  String json=null;
  SQLiteDatabase database=sqliteHelper.getReadableDatabase();
  if (database != null) {
    String[] projection={"String_Node_Str"};
    String key="String_Node_Str";
    String[] value={uri.toString()};
    Cursor cursor=database.query("String_Node_Str",projection,key,value,null,null,null);
    if (cursor != null) {
      json=cursor.moveToFirst() ? cursor.getString(0) : "String_Node_Str";
    }
  }
  boolean isSuccess=json != null;
  String message=null;
  Object item=parseJson(json);
  RestResult result=new RestResult(isSuccess,message,item);
  return result;
}

Fixed version (ground truth):
@Override public RestResult get(Uri uri) throws SQLiteException, InvalidParserException {
  String json=null;
  if (Utils.notEmpty(uri)) {
    SQLiteDatabase database=sqliteHelper.getReadableDatabase();
    String[] projection={"String_Node_Str"};
    String key="String_Node_Str";
    String[] value={uri.toString()};
    Cursor cursor=database.query("String_Node_Str",projection,key,value,null,null,null);
    if (cursor != null) {
      json=cursor.moveToFirst() ? cursor.getString(0) : "String_Node_Str";
    }
  }
  boolean isSuccess=json != null;
  String message=null;
  Object item=parseJson(json);
  RestResult result=new RestResult(isSuccess,message,item);
  return result;
}
Program: 26027
Project: 26027
Buggy source:
@Override public RestResult delete(Uri uri) throws SQLiteException {
  int count=-1;
  SQLiteDatabase database=sqliteHelper.getWritableDatabase();
  if (database != null) {
    String key="String_Node_Str";
    String[] value={uri.toString()};
    count=database.delete("String_Node_Str",key,value);
  }
  boolean isSuccess=count != -1;
  String message=null;
  List<?> items=null;
  RestResult result=new RestResult(isSuccess,message,items);
  return result;
}

Fixed version (ground truth):
@Override public RestResult delete(Uri uri) throws SQLiteException {
  int count=-1;
  if (Utils.notEmpty(uri)) {
    SQLiteDatabase database=sqliteHelper.getWritableDatabase();
    String key="String_Node_Str";
    String[] value={uri.toString()};
    count=database.delete("String_Node_Str",key,value);
  }
  boolean isSuccess=count != -1;
  String message=null;
  List<?> items=null;
  RestResult result=new RestResult(isSuccess,message,items);
  return result;
}
Program: 26028
Project: 26028
Buggy source:
@Override public RestResult put(Uri uri,Object item) throws SQLiteException, InvalidParserException {
  int count=-1;
  SQLiteDatabase database=sqliteHelper.getWritableDatabase();
  if (database != null) {
    String json=parseItem(item);
    String key="String_Node_Str";
    String[] value={uri.toString()};
    ContentValues values=new ContentValues();
    values.put("String_Node_Str",json);
    count=database.updateWithOnConflict("String_Node_Str",values,key,value,SQLiteDatabase.CONFLICT_IGNORE);
  }
  boolean isSuccess=count != -1;
  String message=null;
  List<?> items=null;
  RestResult result=new RestResult(isSuccess,message,items);
  return result;
}

Fixed version (ground truth):
@Override public RestResult put(Uri uri,Object item) throws SQLiteException, InvalidParserException {
  int count=-1;
  if (Utils.notEmpty(uri)) {
    SQLiteDatabase database=sqliteHelper.getWritableDatabase();
    String json=parseItem(item);
    String key="String_Node_Str";
    String[] value={uri.toString()};
    ContentValues values=new ContentValues();
    values.put("String_Node_Str",json);
    count=database.updateWithOnConflict("String_Node_Str",values,key,value,SQLiteDatabase.CONFLICT_IGNORE);
  }
  boolean isSuccess=count != -1;
  String message=null;
  List<?> items=null;
  RestResult result=new RestResult(isSuccess,message,items);
  return result;
}
Program: 26029
Project: 26029
Buggy source:
/** 
 * Verifies that both the database delegate and the network delegate are triggered when a "get" rest request is called. <pre> 1. Create a new CachedRestClient. 2. Add a mocked   {@link DatabaseClientDelegate} to the client.3. Add a mocked  {@link NetworkClientDelegate} to the client.4. Perform a "get" request. 5. Verify that the mocked database delegate is triggered. 6. Verify that the mocked network delegate is triggered. </pre>
 */
public void testGetRequestTriggersBothClientDelegates(){
  targetNetworkDelegate.mock_setMockGetResult(new RestResult(true,null,new Object()));
  targetDatabaseDelegate.mock_setMockPostResult(new RestResult(true,null,null));
  targetDatabaseDelegate.mock_setMockGetResult(new RestResult(true,null,new Object()));
  expectedReportCount=4;
  RestRequest request=buildRestRequest(RestOperation.GET);
  targetRestClient.enqueue(request);
  TestUtils.blockThread();
  assertEquals(2,targetDatabaseDelegate.mock_getGetCallCount());
  assertEquals(1,targetNetworkDelegate.mock_getGetCallCount());
  assertEquals(1,targetDatabaseDelegate.mock_getPostCallCount());
}

Fixed version (ground truth):
/** 
 * Verifies that both the database delegate and the network delegate are triggered when a "get" rest request is called. <pre> 1. Create a new CachedRestClient. 2. Add a mocked   {@link DatabaseClientDelegate} to the client.3. Add a mocked  {@link NetworkClientDelegate} to the client.4. Perform a "get" request. 5. Verify that the mocked database delegate is triggered. 6. Verify that the mocked network delegate is triggered. </pre>
 */
public void testGetRequestTriggersBothClientDelegates(){
  targetNetworkDelegate.mock_setMockGetResult(new RestResult(true,null,new Object()));
  targetDatabaseDelegate.mock_setMockPostResult(new RestResult(true,null,new Object()));
  targetDatabaseDelegate.mock_setMockGetResult(new RestResult(true,null,new Object()));
  expectedReportCount=4;
  RestRequest request=buildRestRequest(RestOperation.GET);
  targetRestClient.enqueue(request);
  TestUtils.blockThread();
  assertEquals(2,targetDatabaseDelegate.mock_getGetCallCount());
  assertEquals(1,targetNetworkDelegate.mock_getGetCallCount());
  assertEquals(1,targetDatabaseDelegate.mock_getPostCallCount());
}
Program: 26030
Project: 26030
Buggy source:
/** 
 * Verifies that a get rest operation is delegated correctly to the  {@link DatabaseClientDelegate}. <pre> 1. Create a new   {@link SQLiteRestClient} and add a mock{@link DatabaseClientDelegate} to it.2. Push a get operation to the client. 3. Verify that the query method of the database helper is called. </pre>
 */
public void testGetOperationIsDelegatedCorrectly(){
  RestRequest restRequest=new RestRequest().setFilter(new PodioFilter()).setOperation(RestOperation.GET);
  target.enqueue(restRequest);
  TestUtils.blockThread(20);
  assertEquals(false,result.isAuthorizeCalled);
  assertEquals(false,result.isDeleteCalled);
  assertEquals(false,result.isInsertCalled);
  assertEquals(true,result.isQueryCalled);
  assertEquals(false,result.isUpdateCalled);
}

Fixed version (ground truth):
/** 
 * Verifies that a get rest operation is delegated correctly to the  {@link DatabaseClientDelegate}. <pre> 1. Create a new   {@link SQLiteRestClient} and add a mock{@link DatabaseClientDelegate} to it.2. Push a get operation to the client. 3. Verify that the query method of the database helper is called. </pre>
 */
public void testGetOperationIsDelegatedCorrectly(){
  RestRequest restRequest=new RestRequest().setFilter(new PodioFilter()).setOperation(RestOperation.GET);
  target.enqueue(restRequest);
  TestUtils.blockThread(40);
  assertEquals(false,result.isAuthorizeCalled);
  assertEquals(false,result.isDeleteCalled);
  assertEquals(false,result.isInsertCalled);
  assertEquals(true,result.isQueryCalled);
  assertEquals(false,result.isUpdateCalled);
}
Program: 26031
Project: 26031
Buggy source:
/** 
 * Verifies that a delete rest operation is delegated correctly to the  {@link DatabaseClientDelegate}. <pre> 1. Create a new   {@link SQLiteRestClient} and add a mock{@link DatabaseClientDelegate} to it.2. Push a delete operation to the client. 3. Verify that the delete method of the database helper is called. </pre>
 */
public void testDeleteOperationIsDelegatedCorrectly(){
  RestRequest restRequest=new RestRequest().setFilter(new PodioFilter()).setOperation(RestOperation.DELETE);
  target.enqueue(restRequest);
  TestUtils.blockThread(20);
  assertEquals(false,result.isAuthorizeCalled);
  assertEquals(true,result.isDeleteCalled);
  assertEquals(false,result.isInsertCalled);
  assertEquals(false,result.isQueryCalled);
  assertEquals(false,result.isUpdateCalled);
}

Fixed version (ground truth):
/** 
 * Verifies that a delete rest operation is delegated correctly to the  {@link DatabaseClientDelegate}. <pre> 1. Create a new   {@link SQLiteRestClient} and add a mock{@link DatabaseClientDelegate} to it.2. Push a delete operation to the client. 3. Verify that the delete method of the database helper is called. </pre>
 */
public void testDeleteOperationIsDelegatedCorrectly(){
  RestRequest restRequest=new RestRequest().setFilter(new PodioFilter()).setOperation(RestOperation.DELETE);
  target.enqueue(restRequest);
  TestUtils.blockThread(40);
  assertEquals(false,result.isAuthorizeCalled);
  assertEquals(true,result.isDeleteCalled);
  assertEquals(false,result.isInsertCalled);
  assertEquals(false,result.isQueryCalled);
  assertEquals(false,result.isUpdateCalled);
}
Program: 26032
Project: 26032
Buggy source:
public void setup(Context context,String clientId,String clientSecret){
  Podio.clientId=clientId;
  Podio.clientSecret=clientSecret;
  Podio.networkDelegate=new HttpClientDelegate(context);
  Podio.cacheDelegate=new SQLiteClientDelegate(context,DATABASE_NAME,DATABASE_VERSION);
  Podio.client=new CachedRestClient(context,AUTHORITY,networkDelegate,cacheDelegate,QUEUE_CAPACITY);
}

Fixed version (ground truth):
public static void setup(Context context,String clientId,String clientSecret){
  Podio.clientId=clientId;
  Podio.clientSecret=clientSecret;
  Podio.networkDelegate=new HttpClientDelegate(context);
  Podio.cacheDelegate=new SQLiteClientDelegate(context,DATABASE_NAME,DATABASE_VERSION);
  Podio.client=new CachedRestClient(context,AUTHORITY,networkDelegate,cacheDelegate,QUEUE_CAPACITY);
}
Program: 26033
Project: 26033
Buggy source:
public static final void authenticateWithCredentials(String username,String password,SessionListener sessionListener){
  networkDelegate.setSessionListener(sessionListener);
  SessionProvider provider=new SessionProvider();
  provider.setRestClient(client);
  provider.authenticateWithUserCredentials(clientId,clientSecret,username,password);
}

Fixed version (ground truth):
public static final Object authenticateWithCredentials(String username,String password,ProviderListener providerListener){
  SessionProvider provider=new SessionProvider();
  provider.setRestClient(client);
  provider.setProviderListener(providerListener);
  return provider.authenticateWithUserCredentials(clientId,clientSecret,username,password);
}
Program: 26034
Project: 26034
Buggy source:
public static final void authenticateWithApp(String appId,String appToken,SessionListener sessionListener){
  networkDelegate.setSessionListener(sessionListener);
  SessionProvider provider=new SessionProvider();
  provider.setRestClient(client);
  provider.authenticateWithAppCredentials(clientId,clientSecret,appId,appToken);
}

Fixed version (ground truth):
public static final Object authenticateWithApp(String appId,String appToken,ProviderListener providerListener){
  SessionProvider provider=new SessionProvider();
  provider.setRestClient(client);
  provider.setProviderListener(providerListener);
  return provider.authenticateWithAppCredentials(clientId,clientSecret,appId,appToken);
}
Program: 26035
Project: 26035
Buggy source:
public boolean isAuthorized(){
  return Utils.notAnyEmpty(accessToken,refreshToken) && expiresInMillis > 0L;
}

Fixed version (ground truth):
public boolean isAuthorized(){
  return Utils.notAnyEmpty(accessToken,refreshToken) && expiresMillis > 0L;
}
Program: 26036
Project: 26036
Buggy source:
public boolean shouldRefreshTokens(){
  long timeLeft=expiresInMillis - System.currentTimeMillis();
  return timeLeft < 600000;
}

Fixed version (ground truth):
public boolean shouldRefreshTokens(){
  long timeLeft=expiresMillis - System.currentTimeMillis();
  return timeLeft < 600000;
}
Program: 26037
Project: 26037
Buggy source:
public Session(String accessToken,String refreshToken,long expiresIn){
  this.accessToken=accessToken;
  this.refreshToken=refreshToken;
  this.expiresInMillis=System.currentTimeMillis() + (expiresIn * 1000);
}

Fixed version (ground truth):
public Session(String accessToken,String refreshToken,long expiresIn){
  this.accessToken=accessToken;
  this.refreshToken=refreshToken;
  this.expiresMillis=System.currentTimeMillis() + (expiresIn * 1000);
}
Program: 26039
Project: 26039
Buggy source:
@Override public void run(){
  if (result == null) {
    resultListener.onFailure(ticket,null);
  }
 else   if (result.isSuccess()) {
    resultListener.onSuccess(ticket,result.item());
  }
 else {
    resultListener.onFailure(ticket,result.message());
  }
}

Fixed version (ground truth):
@Override public void run(){
  if (result == null) {
    resultListener.onFailure(ticket,null);
  }
 else {
    if (result.isSuccess()) {
      resultListener.onSuccess(ticket,result.item());
    }
 else {
      resultListener.onFailure(ticket,result.message());
    }
    Session session=result.session();
    if (session != null) {
      resultListener.onSessionChange(ticket,session);
    }
  }
}