BEEM - Android XMPP Application: Issueshttp://beem-project.com/http://beem-project.com/themes/beem/favicon/favicon.ico?15180459462014-08-14T20:48:50ZBEEM - Android XMPP Application
Redmine BEEM - Android XMPP - Bug #561 (New): NullPointerException (NPE) in Beem Android XMPPhttp://beem-project.com/issues/5612014-08-14T20:48:50ZDanilo Dominguezdxd2290@rit.edu
<p>Dear Beem Team,</p>
<p>I have implemented an static analysis tool for finding bugs in Android apps and I have found a NullPointerException (NPE) in the following class of your app:<br /> - com.beem.project.beem.ui.Chat</p>
<p>What steps will reproduce the problem?<br />1. Open the app with an account set up (I am using a google account).<br />2. Open a chat activity with a friend from your contact list.<br />3. Tab the menu button. <br />4. Tab OTR actions.<br />5. Tab the home button and before the window closes, tab Start OTR session.</p>
<p>This will create a NPE in the Chat activity. It is worth to mention that there are other scenarios in which this bug can be seen. For example, if the user repeat the first 4 steps and receives a phone call, but before the phone call activity takes the foreground, the user tabs in the option Start OTR session. This creates a race condition between the callbacks onPause and onOptionsItemSelected (onPause is called before onOptionsItemSelected). Other apps have had this problem as you can see in bug found in MyTracks [1].</p>
<p>To be more precise, mChatManager is set to null in onPause and then dereference in onOptionsItemSelected in:<br /> try {<br /> if (mChat == null) {<br /> mChat = mChatManager.createChat(mContact, mMessageListener);<br /> if (mChat != null) {<br /> mChat.setOpen(true);<br /> }<br /> }<br /> mChat.startOtrSession();<br /> } catch (RemoteException e) {<br /> Log.e(TAG, "start otr chats failed " + mChat, e);<br /> }</p>
<p>To fix this problem check if the field mChatManager is not null in the callback onOptionsItemSelected.</p>
<p>try {<br /> if (mChat == null &#38;&#38; mChatManager != null) {<br /> mChat = mChatManager.createChat(mContact, mMessageListener);<br /> if (mChat != null) {<br /> mChat.setOpen(true);<br /> }<br /> mChat.startOtrSession();<br /> }<br /> } catch (RemoteException e) {<br /> Log.e(TAG, "start otr chats failed " + mChat, e);<br /> }</p>
<p>What is the expected output? What do you see instead<br />The app crashes. The app must not crash and maintain the same state when the user comeback to the app.</p>
<p>What version of Beem are you using? On what Android version? On what device?<br />Beem 0.1.8 on a Samsung S4 Mini with Android 4.2.2.</p>
<p>Please provide any additional information below.</p>
<p>[1] <a class="external" href="https://code.google.com/p/mytracks/issues/detail?id=741&#38;can=1&#38;q=status%3AFixed&#38;sort=id&#38;colspec=ID%20Type%20Component%20Status%20Priority%20Targeting%20Work%20Stars%20Owner%20Summary&#38;start=200">https://code.google.com/p/mytracks/issues/detail?id=741&#38;can=1&#38;q=status%3AFixed&#38;sort=id&#38;colspec=ID%20Type%20Component%20Status%20Priority%20Targeting%20Work%20Stars%20Owner%20Summary&#38;start=200</a></p>