Program: 33859
Project: 33859
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 cacheInDatabase boolean - do we want to store the response locally if we need to load it from the web?
 * @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 cacheInDatabase,boolean forceFromCache) throws DataManager.NoDataException {
  if (c == null) {
    Log.d("String_Node_Str","String_Node_Str");
    throw new DataManager.NoDataException("String_Node_Str");
  }
  Log.d("String_Node_Str","String_Node_Str" + URL);
  Database db=Database.getInstance(c);
  boolean existsInDb=db.responseExists(URL);
  boolean connectedToInternet=ConnectionDetector.isConnectedToInternet(c);
  if (existsInDb) {
    if (connectedToInternet) {
      APIResponse<String> cachedData=db.getResponse(URL);
      Date now=new Date();
      Date futureTime=new Date(cachedData.lastHit.getTime() + Constants.API_HIT_TIMEOUT);
      System.out.println("String_Node_Str" + cachedData.lastHit + "String_Node_Str"+ futureTime);
      if (now.before(futureTime)) {
        Log.d("String_Node_Str","String_Node_Str");
        return cachedData.updateCode(APIResponse.CODE.CACHED304);
      }
      if (forceFromCache) {
        Log.d("String_Node_Str","String_Node_Str");
        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();
        }
        if (cacheInDatabase) {
          db.updateResponse(URL,response,lastUpdate);
        }
        Log.d("String_Node_Str","String_Node_Str");
        return new APIResponse<>(response,APIResponse.CODE.UPDATED);
      }
 else {
        Log.d("String_Node_Str","String_Node_Str");
        return cachedData.updateCode(APIResponse.CODE.CACHED304);
      }
    }
 else {
      Log.d("String_Node_Str","String_Node_Str");
      return db.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 (cacheInDatabase) {
        db.storeResponse(URL,response,lastUpdate);
      }
      Log.d("String_Node_Str","String_Node_Str");
      return new APIResponse<>(response,APIResponse.CODE.WEBLOAD);
    }
 else {
      Log.d("String_Node_Str","String_Node_Str");
      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 cacheInDatabase boolean - do we want to store the response locally if we need to load it from the web?
 * @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 cacheInDatabase,boolean forceFromCache) throws DataManager.NoDataException {
  if (c == null) {
    Log.d("String_Node_Str","String_Node_Str");
    throw new DataManager.NoDataException("String_Node_Str");
  }
  Log.d("String_Node_Str","String_Node_Str" + URL);
  Database db=Database.getInstance(c);
  boolean existsInDb=db.responseExists(URL);
  boolean connectedToInternet=ConnectionDetector.isConnectedToInternet(c);
  if (existsInDb) {
    if (connectedToInternet) {
      APIResponse<String> cachedData=db.getResponse(URL);
      Date now=new Date();
      Date futureTime=new Date(cachedData.lastHit.getTime() + Constants.API_HIT_TIMEOUT);
      if (now.before(futureTime)) {
        Log.d("String_Node_Str","String_Node_Str");
        return cachedData.updateCode(APIResponse.CODE.CACHED304);
      }
      if (forceFromCache) {
        Log.d("String_Node_Str","String_Node_Str");
        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();
        }
        if (cacheInDatabase) {
          db.updateResponse(URL,response,lastUpdate);
        }
        Log.d("String_Node_Str","String_Node_Str");
        return new APIResponse<>(response,APIResponse.CODE.UPDATED);
      }
 else {
        Log.d("String_Node_Str","String_Node_Str");
        return cachedData.updateCode(APIResponse.CODE.CACHED304);
      }
    }
 else {
      Log.d("String_Node_Str","String_Node_Str");
      return db.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 (cacheInDatabase) {
        db.storeResponse(URL,response,lastUpdate);
      }
      Log.d("String_Node_Str","String_Node_Str");
      return new APIResponse<>(response,APIResponse.CODE.WEBLOAD);
    }
 else {
      Log.d("String_Node_Str","String_Node_Str");
      throw new DataManager.NoDataException("String_Node_Str");
    }
  }
}