Program: 31987
Project: 31987
Buggy source:
/** 
 * Remove the medias older than the provided timestamp.
 * @param timestamp the timestamp (in seconds)
 */
public void removeMediasBefore(final long timestamp){
  final Set<String> filesToKeep=new HashSet<>();
  IMXStore store=getDataHandler().getStore();
  Collection<Room> rooms=store.getRooms();
  for (  Room room : rooms) {
    Collection<Event> events=store.getRoomMessages(room.getRoomId());
    for (    Event event : events) {
      try {
        if (TextUtils.equals(Event.EVENT_TYPE_MESSAGE,event.getType())) {
          JsonElement msgtypeAsVoid=event.getContentAsJsonObject().get("String_Node_Str");
          if (null != msgtypeAsVoid) {
            String msgtype=msgtypeAsVoid.getAsString();
            if (TextUtils.equals(Message.MSGTYPE_IMAGE,msgtype)) {
              ImageMessage imageMessage=(ImageMessage)JsonUtils.toMessage(event.getContent());
              if (null != imageMessage) {
                if (imageMessage.isThumbnailLocalContent()) {
                  filesToKeep.add(Uri.parse(imageMessage.thumbnailUrl).getPath());
                }
                if (imageMessage.isLocalContent()) {
                  filesToKeep.add(Uri.parse(imageMessage.url).getPath());
                }
              }
            }
 else             if (TextUtils.equals(Message.MSGTYPE_VIDEO,msgtype)) {
              VideoMessage videoMessage=(VideoMessage)JsonUtils.toMessage(event.getContent());
              if ((null != videoMessage) && videoMessage.isLocalContent()) {
                filesToKeep.add(Uri.parse(videoMessage.url).getPath());
              }
            }
 else             if (TextUtils.equals(Message.MSGTYPE_FILE,msgtype)) {
              FileMessage fileMessage=(FileMessage)JsonUtils.toMessage(event.getContent());
              if ((null != fileMessage) && fileMessage.isLocalContent()) {
                filesToKeep.add(Uri.parse(fileMessage.url).getPath());
              }
            }
 else             if (TextUtils.equals(Message.MSGTYPE_AUDIO,msgtype)) {
              AudioMessage audioMessage=(AudioMessage)JsonUtils.toMessage(event.getContent());
              if ((null != audioMessage) && audioMessage.isLocalContent()) {
                filesToKeep.add(Uri.parse(audioMessage.url).getPath());
              }
            }
          }
        }
      }
 catch (      Exception e) {
        Log.e(LOG_TAG,"String_Node_Str" + e.getMessage());
      }
    }
  }
  AsyncTask<Void,Void,Long> task=new AsyncTask<Void,Void,Void>(){
    @Override protected Long doInBackground(    Void... params){
      getMediasCache().removeMediasBefore(timestamp,filesToKeep);
      return null;
    }
  }
;
  try {
    task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
  }
 catch (  Exception e) {
    Log.e(LOG_TAG,"String_Node_Str" + e.getMessage());
    task.cancel(true);
  }
}

Fixed version (ground truth):
/** 
 * Remove the medias older than the provided timestamp.
 * @param timestamp the timestamp (in seconds)
 */
public void removeMediasBefore(final long timestamp){
  final Set<String> filesToKeep=new HashSet<>();
  IMXStore store=getDataHandler().getStore();
  Collection<Room> rooms=store.getRooms();
  for (  Room room : rooms) {
    Collection<Event> events=store.getRoomMessages(room.getRoomId());
    for (    Event event : events) {
      try {
        if (TextUtils.equals(Event.EVENT_TYPE_MESSAGE,event.getType())) {
          JsonElement msgtypeAsVoid=event.getContentAsJsonObject().get("String_Node_Str");
          if (null != msgtypeAsVoid) {
            String msgtype=msgtypeAsVoid.getAsString();
            if (TextUtils.equals(Message.MSGTYPE_IMAGE,msgtype)) {
              ImageMessage imageMessage=(ImageMessage)JsonUtils.toMessage(event.getContent());
              if (null != imageMessage) {
                if (imageMessage.isThumbnailLocalContent()) {
                  filesToKeep.add(Uri.parse(imageMessage.thumbnailUrl).getPath());
                }
                if (imageMessage.isLocalContent()) {
                  filesToKeep.add(Uri.parse(imageMessage.url).getPath());
                }
              }
            }
 else             if (TextUtils.equals(Message.MSGTYPE_VIDEO,msgtype)) {
              VideoMessage videoMessage=(VideoMessage)JsonUtils.toMessage(event.getContent());
              if ((null != videoMessage) && videoMessage.isLocalContent()) {
                filesToKeep.add(Uri.parse(videoMessage.url).getPath());
              }
            }
 else             if (TextUtils.equals(Message.MSGTYPE_FILE,msgtype)) {
              FileMessage fileMessage=(FileMessage)JsonUtils.toMessage(event.getContent());
              if ((null != fileMessage) && fileMessage.isLocalContent()) {
                filesToKeep.add(Uri.parse(fileMessage.url).getPath());
              }
            }
 else             if (TextUtils.equals(Message.MSGTYPE_AUDIO,msgtype)) {
              AudioMessage audioMessage=(AudioMessage)JsonUtils.toMessage(event.getContent());
              if ((null != audioMessage) && audioMessage.isLocalContent()) {
                filesToKeep.add(Uri.parse(audioMessage.url).getPath());
              }
            }
          }
        }
      }
 catch (      Exception e) {
        Log.e(LOG_TAG,"String_Node_Str" + e.getMessage());
      }
    }
  }
  AsyncTask<Void,Void,Void> task=new AsyncTask<Void,Void,Void>(){
    @Override protected Void doInBackground(    Void... params){
      getMediasCache().removeMediasBefore(timestamp,filesToKeep);
      return null;
    }
  }
;
  try {
    task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
  }
 catch (  Exception e) {
    Log.e(LOG_TAG,"String_Node_Str" + e.getMessage());
    task.cancel(true);
  }
}