Program: 33823
Project: 33823
Buggy source:
/** 
 * This is the main datafeed method - you speciy a URL and this will either return it from our cache or fetch and store it.
 * @param c               App context
 * @param URL             URL to fetch
 * @param forceFromCache  (optional, defaults to FALSE). If set, the data exists locally, we won't query the web ever - just return what we have.
 * @return An APIRespnse containing the data we fetched from the internet
 * @throws DataManager.NoDataException
 */
public static APIResponse<String> getResponseFromURLOrThrow(Context c,final String URL,boolean cacheLocally,boolean forceFromCache) throws DataManager.NoDataException {
  if (c == null) {
    Log.d(Constants.DATAMANAGER_LOG,"String_Node_Str");
    throw new DataManager.NoDataException("String_Node_Str");
  }
  Log.d(Constants.DATAMANAGER_LOG,"String_Node_Str" + URL);
  boolean existsInDb;
  existsInDb=Database.getInstance(c).getResponseTable().responseExists(URL);
  boolean connectedToInternet=ConnectionDetector.isConnectedToInternet(c);
  if (existsInDb) {
    if (connectedToInternet) {
      APIResponse<String> cachedData;
      cachedData=Database.getInstance(c).getResponseTable().getResponse(URL);
      Date now=new Date();
      Date futureTime=new Date(cachedData.lastHit.getTime() + Constants.API_HIT_TIMEOUT);
      if (now.before(futureTime)) {
        Log.d(Constants.DATAMANAGER_LOG,"String_Node_Str" + URL);
        return cachedData.updateCode(APIResponse.CODE.CACHED304);
      }
      if (forceFromCache) {
        Log.d(Constants.DATAMANAGER_LOG,"String_Node_Str" + URL);
        return cachedData;
      }
      HttpResponse cachedResponse=HTTP.getResponse(URL,cachedData.getLastUpdate());
      boolean dataRequiresUpdate=(cachedResponse != null) && (cachedResponse.getStatusLine().getStatusCode() == 200);
      if (dataRequiresUpdate) {
        String response=HTTP.dataFromResponse(cachedResponse), lastUpdate="String_Node_Str";
        Header lastModified=cachedResponse.getFirstHeader("String_Node_Str");
        if (lastModified != null) {
          lastUpdate=lastModified.getValue();
        }
        Database.getInstance(c).getResponseTable().updateResponse(URL,lastUpdate);
        Log.d(Constants.DATAMANAGER_LOG,"String_Node_Str" + URL);
        return new APIResponse<>(response,APIResponse.CODE.UPDATED);
      }
 else {
        Database.getInstance(c).getResponseTable().touchResponse(URL);
        Log.d(Constants.DATAMANAGER_LOG,"String_Node_Str" + URL);
        return cachedData.updateCode(APIResponse.CODE.CACHED304);
      }
    }
 else {
      Log.d(Constants.DATAMANAGER_LOG,"String_Node_Str" + URL);
      return Database.getInstance(c).getResponseTable().getResponse(URL).updateCode(APIResponse.CODE.OFFLINECACHE);
    }
  }
 else {
    if (connectedToInternet) {
      HttpResponse cachedResponse=HTTP.getResponse(URL);
      String response=HTTP.dataFromResponse(cachedResponse), lastUpdate="String_Node_Str";
      Header lastModified=cachedResponse.getFirstHeader("String_Node_Str");
      if (lastModified != null) {
        lastUpdate=lastModified.getValue();
      }
      if (cacheLocally) {
        Database.getInstance(c).getResponseTable().storeResponse(URL,lastUpdate);
      }
      Log.d(Constants.DATAMANAGER_LOG,"String_Node_Str" + URL);
      return new APIResponse<>(response,APIResponse.CODE.WEBLOAD);
    }
 else {
      Log.d(Constants.DATAMANAGER_LOG,"String_Node_Str" + URL);
      throw new DataManager.NoDataException("String_Node_Str");
    }
  }
}

Fixed version (ground truth):
/** 
 * This is the main datafeed method - you speciy a URL and this will either return it from our cache or fetch and store it.
 * @param c               App context
 * @param URL             URL to fetch
 * @param forceFromCache  (optional, defaults to FALSE). If set, the data exists locally, we won't query the web ever - just return what we have.
 * @return An APIRespnse containing the data we fetched from the internet
 * @throws DataManager.NoDataException
 */
public static APIResponse<String> getResponseFromURLOrThrow(Context c,final String URL,boolean cacheLocally,boolean forceFromCache) throws DataManager.NoDataException {
  if (c == null) {
    Log.d(Constants.DATAMANAGER_LOG,"String_Node_Str");
    throw new DataManager.NoDataException("String_Node_Str");
  }
  boolean existsInDb;
  existsInDb=Database.getInstance(c).getResponseTable().responseExists(URL);
  boolean connectedToInternet=ConnectionDetector.isConnectedToInternet(c);
  if (existsInDb) {
    if (connectedToInternet) {
      APIResponse<String> cachedData;
      cachedData=Database.getInstance(c).getResponseTable().getResponse(URL);
      Date now=new Date();
      Date futureTime=new Date(cachedData.lastHit.getTime() + Constants.API_HIT_TIMEOUT);
      if (now.before(futureTime)) {
        return cachedData.updateCode(APIResponse.CODE.CACHED304);
      }
      if (forceFromCache) {
        return cachedData;
      }
      HttpResponse cachedResponse=HTTP.getResponse(URL,cachedData.getLastUpdate());
      boolean dataRequiresUpdate=(cachedResponse != null) && (cachedResponse.getStatusLine().getStatusCode() == 200);
      if (dataRequiresUpdate) {
        String response=HTTP.dataFromResponse(cachedResponse), lastUpdate="String_Node_Str";
        Header lastModified=cachedResponse.getFirstHeader("String_Node_Str");
        if (lastModified != null) {
          lastUpdate=lastModified.getValue();
        }
        Database.getInstance(c).getResponseTable().updateResponse(URL,lastUpdate);
        Log.d(Constants.DATAMANAGER_LOG,"String_Node_Str" + URL);
        return new APIResponse<>(response,APIResponse.CODE.UPDATED);
      }
 else {
        Database.getInstance(c).getResponseTable().touchResponse(URL);
        return cachedData.updateCode(APIResponse.CODE.CACHED304);
      }
    }
 else {
      Log.d(Constants.DATAMANAGER_LOG,"String_Node_Str" + URL);
      return Database.getInstance(c).getResponseTable().getResponse(URL).updateCode(APIResponse.CODE.OFFLINECACHE);
    }
  }
 else {
    if (connectedToInternet) {
      HttpResponse cachedResponse=HTTP.getResponse(URL);
      String response=HTTP.dataFromResponse(cachedResponse), lastUpdate="String_Node_Str";
      Header lastModified=cachedResponse.getFirstHeader("String_Node_Str");
      if (lastModified != null) {
        lastUpdate=lastModified.getValue();
      }
      if (cacheLocally) {
        Database.getInstance(c).getResponseTable().storeResponse(URL,lastUpdate);
      }
      Log.d(Constants.DATAMANAGER_LOG,"String_Node_Str" + URL);
      return new APIResponse<>(response,APIResponse.CODE.WEBLOAD);
    }
 else {
      Log.d(Constants.DATAMANAGER_LOG,"String_Node_Str" + URL);
      throw new DataManager.NoDataException("String_Node_Str");
    }
  }
}