Program: 26038
Project: 26038
Buggy source:
/** 
 * Performs a custom rest request flow, by - generally speaking - allowing all requests to be handled by the super network client implementation first. When the super implementation delivers a result, that result is stored by this implementation in a local database. The stored data is then requested immediately after and returned to the caller. One exception from the above flow is the GET rest requests, which actually return the cached content first and then re-posts the same request to be handled by the network client as well according to the above pattern.
 * @see com.podio.sdk.client.HttpRestClient#handleRequest(com.podio.sdk.client.RestRequest)
 */
@Override protected RestResult handleRequest(RestRequest restRequest){
  RestResult result=null;
  if (restRequest != null) {
    RestOperation operation=restRequest.getOperation();
    Filter filter=restRequest.getFilter();
    Object item=restRequest.getContent();
    Class<?> itemType=restRequest.getItemType();
    Uri uri=filter.buildUri(contentScheme,authority);
    if (uri != null && itemType != null) {
      if (operation == RestOperation.GET && !delegatedRequests.contains(restRequest)) {
        result=delegate(operation,uri,item,itemType);
        delegatedRequests.add(restRequest);
        super.enqueue(restRequest);
      }
 else {
        delegatedRequests.remove(restRequest);
        result=super.handleRequest(restRequest);
        if (result.isSuccess() && operation != RestOperation.AUTHORIZE) {
          if (operation == RestOperation.GET) {
            result=delegate(RestOperation.POST,uri,item,itemType);
          }
 else {
            result=delegate(operation,uri,item,itemType);
          }
        }
        if (result.isSuccess() && operation != RestOperation.AUTHORIZE) {
          result=delegate(RestOperation.GET,uri,item,itemType);
        }
      }
    }
  }
  return result != null ? result : new RestResult(false,null,null);
}

Fixed version (ground truth):
/** 
 * Performs a custom rest request flow, by - generally speaking - allowing all requests to be handled by the super network client implementation first. When the super implementation delivers a result, that result is stored by this implementation in a local database. The stored data is then requested immediately after and returned to the caller. One exception from the above flow is the GET rest requests, which actually return the cached content first and then re-posts the same request to be handled by the network client as well according to the above pattern.
 * @see com.podio.sdk.client.HttpRestClient#handleRequest(com.podio.sdk.client.RestRequest)
 */
@Override protected RestResult handleRequest(RestRequest restRequest){
  RestResult result=null;
  if (restRequest != null) {
    RestOperation operation=restRequest.getOperation();
    Filter filter=restRequest.getFilter();
    Object item=restRequest.getContent();
    Class<?> itemType=restRequest.getItemType();
    Uri uri=filter.buildUri(contentScheme,authority);
    if (Utils.notEmpty(uri)) {
      if (operation == RestOperation.GET && !delegatedRequests.contains(restRequest)) {
        result=delegate(operation,uri,item,itemType);
        delegatedRequests.add(restRequest);
        super.enqueue(restRequest);
      }
 else {
        delegatedRequests.remove(restRequest);
        result=super.handleRequest(restRequest);
        if (result.isSuccess() && operation != RestOperation.AUTHORIZE) {
          if (operation == RestOperation.GET) {
            result=delegate(RestOperation.POST,uri,item,itemType);
          }
 else {
            result=delegate(operation,uri,item,itemType);
          }
        }
        if (result.isSuccess() && operation != RestOperation.AUTHORIZE) {
          result=delegate(RestOperation.GET,uri,item,itemType);
        }
      }
    }
  }
  return result != null ? result : new RestResult(false,null,null);
}