Program: 26016
Project: 26016
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();
    Uri uri=filter.buildUri(contentScheme,authority);
    if (Utils.notEmpty(uri)) {
      if (operation == RestOperation.GET && !delegatedRequests.contains(restRequest)) {
        result=delegate(operation,uri,item);
        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);
          }
 else {
            result=delegate(operation,uri,item);
          }
        }
        if (result.isSuccess() && operation != RestOperation.AUTHORIZE) {
          result=delegate(RestOperation.GET,uri,item);
        }
      }
    }
  }
  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();
    Uri uri=filter.buildUri(contentScheme,authority);
    if (Utils.notEmpty(uri)) {
      if (operation == RestOperation.GET && !delegatedRequests.contains(restRequest)) {
        result=delegate(operation,uri,item);
        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,result.item());
          }
 else {
            result=delegate(operation,uri,result.item());
          }
        }
        if (result.isSuccess() && operation != RestOperation.AUTHORIZE) {
          result=delegate(RestOperation.GET,uri,null);
        }
      }
    }
  }
  return result != null ? result : new RestResult(false,null,null);
}