Program: 31979
Project: 31979
Buggy source:
/** 
 * Create a user session with a data handler.
 * @param hsConfig    the home server connection config
 * @param dataHandler the data handler
 * @param appContext  the application context
 */
public MXSession(HomeServerConnectionConfig hsConfig,MXDataHandler dataHandler,Context appContext){
  this(hsConfig);
  mDataHandler=dataHandler;
  mDataHandler.getStore().addMXStoreListener(new MXStoreListener(){
    @Override public void onStoreReady(    String accountId){
      getDataHandler().checkPermanentStorageData();
      getDataHandler().onStoreReady();
    }
    @Override public void onStoreCorrupted(    String accountId,    String description){
      if (null == getDataHandler().getStore()) {
        getDataHandler().onStoreReady();
      }
    }
    @Override public void postProcess(    String accountId){
      if (null == mCrypto) {
        MXFileCryptoStore store=new MXFileCryptoStore();
        store.initWithCredentials(mAppContent,mCredentials);
        if (store.hasData() || mEnableCryptoWhenStartingMXSession) {
          Log.d(LOG_TAG,"String_Node_Str" + this);
          checkCrypto();
        }
 else {
          Log.e(LOG_TAG,"String_Node_Str");
        }
      }
 else {
        Log.e(LOG_TAG,"String_Node_Str");
      }
    }
    @Override public void onReadReceiptsLoaded(    final String roomId){
      final List<ReceiptData> receipts=mDataHandler.getStore().getEventReceipts(roomId,null,false,false);
      final ArrayList<String> senders=new ArrayList<>();
      for (      ReceiptData receipt : receipts) {
        senders.add(receipt.userId);
      }
      mDataHandler.onReceiptEvent(roomId,senders);
    }
  }
);
  mDataRetriever=new DataRetriever();
  mDataRetriever.setRoomsRestClient(mRoomsRestClient);
  mDataHandler.setDataRetriever(mDataRetriever);
  mDataHandler.setProfileRestClient(mProfileRestClient);
  mDataHandler.setPresenceRestClient(mPresenceRestClient);
  mDataHandler.setThirdPidRestClient(mThirdPidRestClient);
  mDataHandler.setRoomsRestClient(mRoomsRestClient);
  mDataHandler.setEventsRestClient(mEventsRestClient);
  mAppContent=appContext;
  mNetworkConnectivityReceiver=new NetworkConnectivityReceiver();
  mNetworkConnectivityReceiver.checkNetworkConnection(appContext);
  mDataHandler.setNetworkConnectivityReceiver(mNetworkConnectivityReceiver);
  mAppContent.registerReceiver(mNetworkConnectivityReceiver,new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION));
  mBingRulesManager=new BingRulesManager(this,mNetworkConnectivityReceiver);
  mDataHandler.setPushRulesManager(mBingRulesManager);
  mUnsentEventsManager=new UnsentEventsManager(mNetworkConnectivityReceiver,mDataHandler);
  mContentManager=new ContentManager(hsConfig,mUnsentEventsManager);
  mCallsManager=new MXCallsManager(this,mAppContent);
  mDataHandler.setCallsManager(mCallsManager);
  mEventsRestClient.setUnsentEventsManager(mUnsentEventsManager);
  mProfileRestClient.setUnsentEventsManager(mUnsentEventsManager);
  mPresenceRestClient.setUnsentEventsManager(mUnsentEventsManager);
  mRoomsRestClient.setUnsentEventsManager(mUnsentEventsManager);
  mBingRulesRestClient.setUnsentEventsManager(mUnsentEventsManager);
  mThirdPidRestClient.setUnsentEventsManager(mUnsentEventsManager);
  mCallRestClient.setUnsentEventsManager(mUnsentEventsManager);
  mAccountDataRestClient.setUnsentEventsManager(mUnsentEventsManager);
  mCryptoRestClient.setUnsentEventsManager(mUnsentEventsManager);
  mLoginRestClient.setUnsentEventsManager(mUnsentEventsManager);
  mLatestChatMessageCache=new MXLatestChatMessageCache(mCredentials.userId);
  mMediasCache=new MXMediasCache(mContentManager,mNetworkConnectivityReceiver,mCredentials.userId,appContext);
  mDataHandler.setMediasCache(mMediasCache);
}

Fixed version (ground truth):
/** 
 * Create a user session with a data handler.
 * @param hsConfig    the home server connection config
 * @param dataHandler the data handler
 * @param appContext  the application context
 */
public MXSession(HomeServerConnectionConfig hsConfig,MXDataHandler dataHandler,Context appContext){
  this(hsConfig);
  mDataHandler=dataHandler;
  mDataHandler.getStore().addMXStoreListener(new MXStoreListener(){
    @Override public void onStoreReady(    String accountId){
      getDataHandler().checkPermanentStorageData();
      getDataHandler().onStoreReady();
    }
    @Override public void onStoreCorrupted(    String accountId,    String description){
      if (null == getDataHandler().getStore()) {
        getDataHandler().onStoreReady();
      }
    }
    @Override public void postProcess(    String accountId){
      if (null == mCrypto) {
        MXFileCryptoStore store=new MXFileCryptoStore();
        store.initWithCredentials(mAppContent,mCredentials);
        if (store.hasData() || mEnableCryptoWhenStartingMXSession) {
          Log.d(LOG_TAG,"String_Node_Str" + this);
          checkCrypto();
        }
 else {
          Log.e(LOG_TAG,"String_Node_Str");
        }
      }
 else {
        Log.e(LOG_TAG,"String_Node_Str");
      }
    }
    @Override public void onReadReceiptsLoaded(    final String roomId){
      final List<ReceiptData> receipts=mDataHandler.getStore().getEventReceipts(roomId,null,false,false);
      final ArrayList<String> senders=new ArrayList<>();
      for (      ReceiptData receipt : receipts) {
        senders.add(receipt.userId);
      }
      mDataHandler.onReceiptEvent(roomId,senders);
    }
  }
);
  mDataRetriever=new DataRetriever();
  mDataRetriever.setRoomsRestClient(mRoomsRestClient);
  mDataHandler.setDataRetriever(mDataRetriever);
  mDataHandler.setProfileRestClient(mProfileRestClient);
  mDataHandler.setPresenceRestClient(mPresenceRestClient);
  mDataHandler.setThirdPidRestClient(mThirdPidRestClient);
  mDataHandler.setRoomsRestClient(mRoomsRestClient);
  mDataHandler.setEventsRestClient(mEventsRestClient);
  mDataHandler.setAccountDataRestClient(mAccountDataRestClient);
  mAppContent=appContext;
  mNetworkConnectivityReceiver=new NetworkConnectivityReceiver();
  mNetworkConnectivityReceiver.checkNetworkConnection(appContext);
  mDataHandler.setNetworkConnectivityReceiver(mNetworkConnectivityReceiver);
  mAppContent.registerReceiver(mNetworkConnectivityReceiver,new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION));
  mBingRulesManager=new BingRulesManager(this,mNetworkConnectivityReceiver);
  mDataHandler.setPushRulesManager(mBingRulesManager);
  mUnsentEventsManager=new UnsentEventsManager(mNetworkConnectivityReceiver,mDataHandler);
  mContentManager=new ContentManager(hsConfig,mUnsentEventsManager);
  mCallsManager=new MXCallsManager(this,mAppContent);
  mDataHandler.setCallsManager(mCallsManager);
  mEventsRestClient.setUnsentEventsManager(mUnsentEventsManager);
  mProfileRestClient.setUnsentEventsManager(mUnsentEventsManager);
  mPresenceRestClient.setUnsentEventsManager(mUnsentEventsManager);
  mRoomsRestClient.setUnsentEventsManager(mUnsentEventsManager);
  mBingRulesRestClient.setUnsentEventsManager(mUnsentEventsManager);
  mThirdPidRestClient.setUnsentEventsManager(mUnsentEventsManager);
  mCallRestClient.setUnsentEventsManager(mUnsentEventsManager);
  mAccountDataRestClient.setUnsentEventsManager(mUnsentEventsManager);
  mCryptoRestClient.setUnsentEventsManager(mUnsentEventsManager);
  mLoginRestClient.setUnsentEventsManager(mUnsentEventsManager);
  mLatestChatMessageCache=new MXLatestChatMessageCache(mCredentials.userId);
  mMediasCache=new MXMediasCache(mContentManager,mNetworkConnectivityReceiver,mCredentials.userId,appContext);
  mDataHandler.setMediasCache(mMediasCache);
}