Program: 31973
Project: 31973
Buggy source:
/** 
 * Open the store.
 */
@Override public void open(){
  super.open();
  final long fLoadTimeT0=System.currentTimeMillis();
synchronized (this) {
    if (!mIsReady && !mIsOpening && (null != mMetadata)&& (null != mHandlerThread)) {
      mIsOpening=true;
      Log.e(LOG_TAG,"String_Node_Str");
      if (null == mFileStoreHandler) {
        try {
          mHandlerThread.start();
        }
 catch (        IllegalThreadStateException e) {
          Log.e(LOG_TAG,"String_Node_Str");
          return;
        }
        mFileStoreHandler=new MXOsHandler(mHandlerThread.getLooper());
      }
      Runnable r=new Runnable(){
        @Override public void run(){
          mFileStoreHandler.post(new Runnable(){
            public void run(){
              Log.e(LOG_TAG,"String_Node_Str");
              String errorDescription=null;
              boolean succeed=(mMetadata.mVersion == MXFILE_VERSION) && TextUtils.equals(mMetadata.mUserId,mCredentials.userId) && TextUtils.equals(mMetadata.mAccessToken,mCredentials.accessToken);
              if (!succeed) {
                errorDescription="String_Node_Str";
                Log.e(LOG_TAG,errorDescription);
              }
              if (succeed) {
                succeed&=loadRoomsMessages();
                if (!succeed) {
                  errorDescription="String_Node_Str";
                  Log.e(LOG_TAG,errorDescription);
                }
 else {
                  Log.e(LOG_TAG,"String_Node_Str");
                }
              }
              if (succeed) {
                succeed&=loadRoomsState();
                if (!succeed) {
                  errorDescription="String_Node_Str";
                  Log.e(LOG_TAG,errorDescription);
                }
 else {
                  Log.e(LOG_TAG,"String_Node_Str");
                  long t0=System.currentTimeMillis();
                  Log.e(LOG_TAG,"String_Node_Str");
                  Collection<Room> rooms=getRooms();
                  for (                  Room room : rooms) {
                    Collection<RoomMember> members=room.getLiveState().getMembers();
                    for (                    RoomMember member : members) {
                      updateUserWithRoomMemberEvent(member);
                    }
                  }
                  long delta=System.currentTimeMillis() - t0;
                  Log.e(LOG_TAG,"String_Node_Str" + mUsers.size() + "String_Node_Str"+ delta+ "String_Node_Str");
                  mStoreStats.put("String_Node_Str",delta);
                }
              }
              if (succeed) {
                succeed&=loadSummaries();
                if (!succeed) {
                  errorDescription="String_Node_Str";
                  Log.e(LOG_TAG,errorDescription);
                }
 else {
                  Log.e(LOG_TAG,"String_Node_Str");
                  for (                  String roomId : mRoomSummaries.keySet()) {
                    Room room=getRoom(roomId);
                    if (null == room) {
                      succeed=false;
                      Log.e(LOG_TAG,"String_Node_Str" + roomId + "String_Node_Str");
                    }
 else                     if (null == room.getMember(mCredentials.userId)) {
                      succeed=false;
                      Log.e(LOG_TAG,"String_Node_Str" + roomId + "String_Node_Str");
                    }
                  }
                }
              }
              if (succeed) {
                succeed&=loadRoomsAccountData();
                if (!succeed) {
                  errorDescription="String_Node_Str";
                  Log.e(LOG_TAG,errorDescription);
                }
 else {
                  Log.e(LOG_TAG,"String_Node_Str");
                }
              }
              if (!succeed) {
                Log.e(LOG_TAG,"String_Node_Str");
                MXFileStoreMetaData tmpMetadata=mMetadata;
                deleteAllData(true);
                mRoomsToCommitForMessages=new HashSet<>();
                mRoomsToCommitForStates=new HashSet<>();
                mRoomsToCommitForSummaries=new HashSet<>();
                mRoomsToCommitForReceipts=new HashSet<>();
                mMetadata=tmpMetadata;
                if (null == mMetadata) {
                  mMetadata=new MXFileStoreMetaData();
                  mMetadata.mUserId=mCredentials.userId;
                  mMetadata.mAccessToken=mCredentials.accessToken;
                  mMetaDataHasChanged=true;
                }
 else {
                  mMetadata.mEventStreamToken=null;
                }
                mMetadata.mVersion=MXFILE_VERSION;
                mEventStreamToken=null;
                mAreReceiptsReady=true;
              }
 else {
                Log.d(LOG_TAG,"String_Node_Str");
                Set<String> roomIds=mRoomEvents.keySet();
                for (                String roomId : roomIds) {
                  Room room=getRoom(roomId);
                  if ((null != room) && (null != room.getLiveState())) {
                    int membersCount=room.getLiveState().getMembers().size();
                    int eventsCount=mRoomEvents.get(roomId).size();
                    Log.d(LOG_TAG,"String_Node_Str" + roomId + "String_Node_Str"+ membersCount+ "String_Node_Str"+ eventsCount);
                  }
                }
                Log.d(LOG_TAG,"String_Node_Str");
              }
synchronized (this) {
                mIsReady=true;
              }
              mIsOpening=false;
              Log.e(LOG_TAG,"String_Node_Str");
              dispatchPostProcess(mCredentials.userId);
              mIsPostProcessingDone=true;
              if (!succeed && !mIsNewStorage) {
                Log.e(LOG_TAG,"String_Node_Str");
                dispatchOnStoreCorrupted(mCredentials.userId,errorDescription);
              }
 else {
                mRoomReceiptsToLoad.addAll(listFiles(mStoreRoomsMessagesReceiptsFolderFile.list()));
                mPreloadTime=System.currentTimeMillis() - fLoadTimeT0;
                Log.e(LOG_TAG,"String_Node_Str");
                dispatchOnStoreReady(mCredentials.userId);
                loadReceipts();
                loadUsers();
              }
            }
          }
);
        }
      }
;
      Thread t=new Thread(r);
      t.start();
    }
 else     if (mIsReady) {
      Runnable r=new Runnable(){
        @Override public void run(){
          mFileStoreHandler.post(new Runnable(){
            @Override public void run(){
              if (!mIsPostProcessingDone && !mIsNewStorage) {
                Log.e(LOG_TAG,"String_Node_Str");
                return;
              }
 else {
                if (!mIsPostProcessingDone) {
                  Log.e(LOG_TAG,"String_Node_Str");
                  dispatchPostProcess(mCredentials.userId);
                  mIsPostProcessingDone=true;
                }
 else {
                  Log.e(LOG_TAG,"String_Node_Str");
                }
                dispatchOnStoreReady(mCredentials.userId);
                mPreloadTime=System.currentTimeMillis() - fLoadTimeT0;
              }
            }
          }
);
        }
      }
;
      Thread t=new Thread(r);
      t.start();
    }
  }
}

Fixed version (ground truth):
/** 
 * Open the store.
 */
@Override public void open(){
  super.open();
  final long fLoadTimeT0=System.currentTimeMillis();
synchronized (this) {
    if (!mIsReady && !mIsOpening && (null != mMetadata)&& (null != mHandlerThread)) {
      mIsOpening=true;
      Log.e(LOG_TAG,"String_Node_Str");
      if (null == mFileStoreHandler) {
        try {
          mHandlerThread.start();
        }
 catch (        IllegalThreadStateException e) {
          Log.e(LOG_TAG,"String_Node_Str");
          return;
        }
        mFileStoreHandler=new MXOsHandler(mHandlerThread.getLooper());
      }
      Runnable r=new Runnable(){
        @Override public void run(){
          mFileStoreHandler.post(new Runnable(){
            public void run(){
              Log.e(LOG_TAG,"String_Node_Str");
              String errorDescription=null;
              boolean succeed=(mMetadata.mVersion == MXFILE_VERSION) && TextUtils.equals(mMetadata.mUserId,mCredentials.userId) && TextUtils.equals(mMetadata.mAccessToken,mCredentials.accessToken);
              if (!succeed) {
                errorDescription="String_Node_Str";
                Log.e(LOG_TAG,errorDescription);
              }
              if (succeed) {
                succeed&=loadRoomsMessages();
                if (!succeed) {
                  errorDescription="String_Node_Str";
                  Log.e(LOG_TAG,errorDescription);
                }
 else {
                  Log.e(LOG_TAG,"String_Node_Str");
                }
              }
              if (succeed) {
                succeed&=loadRoomsState();
                if (!succeed) {
                  errorDescription="String_Node_Str";
                  Log.e(LOG_TAG,errorDescription);
                }
 else {
                  Log.e(LOG_TAG,"String_Node_Str");
                  long t0=System.currentTimeMillis();
                  Log.e(LOG_TAG,"String_Node_Str");
                  Collection<Room> rooms=getRooms();
                  for (                  Room room : rooms) {
                    Collection<RoomMember> members=room.getLiveState().getMembers();
                    for (                    RoomMember member : members) {
                      updateUserWithRoomMemberEvent(member);
                    }
                  }
                  long delta=System.currentTimeMillis() - t0;
                  Log.e(LOG_TAG,"String_Node_Str" + mUsers.size() + "String_Node_Str"+ delta+ "String_Node_Str");
                  mStoreStats.put("String_Node_Str",delta);
                }
              }
              if (succeed) {
                succeed&=loadSummaries();
                if (!succeed) {
                  errorDescription="String_Node_Str";
                  Log.e(LOG_TAG,errorDescription);
                }
 else {
                  Log.e(LOG_TAG,"String_Node_Str");
                  for (                  String roomId : mRoomSummaries.keySet()) {
                    Room room=getRoom(roomId);
                    if (null == room) {
                      succeed=false;
                      Log.e(LOG_TAG,"String_Node_Str" + roomId + "String_Node_Str");
                    }
 else                     if (null == room.getMember(mCredentials.userId)) {
                      succeed=false;
                      Log.e(LOG_TAG,"String_Node_Str" + roomId + "String_Node_Str");
                    }
                  }
                }
              }
              if (succeed) {
                succeed&=loadRoomsAccountData();
                if (!succeed) {
                  errorDescription="String_Node_Str";
                  Log.e(LOG_TAG,errorDescription);
                }
 else {
                  Log.e(LOG_TAG,"String_Node_Str");
                }
              }
              if (!succeed) {
                Log.e(LOG_TAG,"String_Node_Str");
                MXFileStoreMetaData tmpMetadata=mMetadata;
                deleteAllData(true);
                mRoomsToCommitForMessages=new HashSet<>();
                mRoomsToCommitForStates=new HashSet<>();
                mRoomsToCommitForSummaries=new HashSet<>();
                mRoomsToCommitForReceipts=new HashSet<>();
                mMetadata=tmpMetadata;
                if (null == mMetadata) {
                  mMetadata=new MXFileStoreMetaData();
                  mMetadata.mUserId=mCredentials.userId;
                  mMetadata.mAccessToken=mCredentials.accessToken;
                  mMetaDataHasChanged=true;
                }
 else {
                  mMetadata.mEventStreamToken=null;
                }
                mMetadata.mVersion=MXFILE_VERSION;
                mEventStreamToken=null;
                mAreReceiptsReady=true;
              }
 else {
                Log.d(LOG_TAG,"String_Node_Str");
                Set<String> roomIds=mRoomEvents.keySet();
                for (                String roomId : roomIds) {
                  Room room=getRoom(roomId);
                  if ((null != room) && (null != room.getLiveState())) {
                    int membersCount=room.getLiveState().getMembers().size();
                    int eventsCount=mRoomEvents.get(roomId).size();
                    Log.d(LOG_TAG,"String_Node_Str" + roomId + "String_Node_Str"+ membersCount+ "String_Node_Str"+ eventsCount);
                  }
                }
                Log.d(LOG_TAG,"String_Node_Str");
              }
              Log.d(LOG_TAG,"String_Node_Str");
              dispatchPostProcess(mCredentials.userId);
              mIsPostProcessingDone=true;
synchronized (this) {
                mIsReady=true;
              }
              mIsOpening=false;
              if (!succeed && !mIsNewStorage) {
                Log.e(LOG_TAG,"String_Node_Str");
                dispatchOnStoreCorrupted(mCredentials.userId,errorDescription);
              }
 else {
                mRoomReceiptsToLoad.addAll(listFiles(mStoreRoomsMessagesReceiptsFolderFile.list()));
                mPreloadTime=System.currentTimeMillis() - fLoadTimeT0;
                Log.e(LOG_TAG,"String_Node_Str");
                dispatchOnStoreReady(mCredentials.userId);
                loadReceipts();
                loadUsers();
              }
            }
          }
);
        }
      }
;
      Thread t=new Thread(r);
      t.start();
    }
 else     if (mIsReady) {
      Runnable r=new Runnable(){
        @Override public void run(){
          mFileStoreHandler.post(new Runnable(){
            @Override public void run(){
              if (!mIsPostProcessingDone && !mIsNewStorage) {
                Log.e(LOG_TAG,"String_Node_Str");
                return;
              }
 else {
                if (!mIsPostProcessingDone) {
                  Log.e(LOG_TAG,"String_Node_Str");
                  dispatchPostProcess(mCredentials.userId);
                  mIsPostProcessingDone=true;
                }
 else {
                  Log.e(LOG_TAG,"String_Node_Str");
                }
                dispatchOnStoreReady(mCredentials.userId);
                mPreloadTime=System.currentTimeMillis() - fLoadTimeT0;
              }
            }
          }
);
        }
      }
;
      Thread t=new Thread(r);
      t.start();
    }
  }
}