Skip to content

Commit

Permalink
fix? NPE for currentUser in ConversationList
Browse files Browse the repository at this point in the history
On gplay console this was reported (not often).

It looks like currentUser could be null when getRoomsFlow is updated.

Maybe for some cases initialization was too late in onResume, so moved to onCreate. Not reproduced/tested though.

Exception java.lang.NullPointerException:
  at com.nextcloud.talk.conversationlist.ConversationsListActivity.addToConversationItems (ConversationsListActivity.kt:837)
  at com.nextcloud.talk.conversationlist.ConversationsListActivity.access$addToConversationItems (ConversationsListActivity.kt:149)
  at com.nextcloud.talk.conversationlist.ConversationsListActivity$initObservers$5$1.invokeSuspend (ConversationsListActivity.kt:379)
  at com.nextcloud.talk.conversationlist.ConversationsListActivity$initObservers$5$1.invoke (Unknown Source:8)
  at com.nextcloud.talk.conversationlist.ConversationsListActivity$initObservers$5$1.invoke (Unknown Source:4)
  at kotlinx.coroutines.flow.FlowKt__TransformKt$onEach$$inlined$unsafeTransform$1$2.emit (Emitters.kt:219)
  at kotlinx.coroutines.flow.FlowKt__ErrorsKt$catchImpl$2.emit (Errors.kt:154)
  at kotlinx.coroutines.flow.FlowKt__TransformKt$onEach$$inlined$unsafeTransform$1$2.emit (Emitters.kt:220)
  at kotlinx.coroutines.flow.SharedFlowImpl.collect$suspendImpl (SharedFlow.kt:392)
  at kotlinx.coroutines.flow.SharedFlowImpl.collect (Unknown Source)
  at kotlinx.coroutines.flow.FlowKt__TransformKt$onEach$$inlined$unsafeTransform$1.collect (SafeCollector.common.kt:112)
  at kotlinx.coroutines.flow.FlowKt__ErrorsKt.catchImpl (Errors.kt:152)
  at kotlinx.coroutines.flow.FlowKt.catchImpl (Unknown Source:1)
  at kotlinx.coroutines.flow.FlowKt__ErrorsKt$catch$$inlined$unsafeFlow$1.collect (SafeCollector.common.kt:112)
  at kotlinx.coroutines.flow.FlowKt__TransformKt$onEach$$inlined$unsafeTransform$1.collect (SafeCollector.common.kt:112)
  at kotlinx.coroutines.flow.FlowKt__CollectKt.collect (Collect.kt:26)
  at kotlinx.coroutines.flow.FlowKt.collect (Unknown Source:1)
  at com.nextcloud.talk.conversationlist.ConversationsListActivity$initObservers$5.invokeSuspend (ConversationsListActivity.kt:396)
  at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith (ContinuationImpl.kt:33)
  at kotlinx.coroutines.internal.DispatchedContinuationKt.resumeCancellableWith (DispatchedContinuation.kt:363)
  at kotlinx.coroutines.intrinsics.CancellableKt.startCoroutineCancellable (Cancellable.kt:26)
  at kotlinx.coroutines.intrinsics.CancellableKt.startCoroutineCancellable$default (Cancellable.kt:21)
  at kotlinx.coroutines.CoroutineStart.invoke (CoroutineStart.kt:88)
  at kotlinx.coroutines.AbstractCoroutine.start (AbstractCoroutine.kt:123)
  at kotlinx.coroutines.BuildersKt__Builders_commonKt.launch (Builders.common.kt:52)
  at kotlinx.coroutines.BuildersKt.launch (Unknown Source:1)
  at kotlinx.coroutines.BuildersKt__Builders_commonKt.launch$default (Builders.common.kt:43)
  at kotlinx.coroutines.BuildersKt.launch$default (Unknown Source:1)
  at com.nextcloud.talk.conversationlist.ConversationsListActivity.initObservers (ConversationsListActivity.kt:372)
  at com.nextcloud.talk.conversationlist.ConversationsListActivity.onCreate (ConversationsListActivity.kt:246)
  at android.app.Activity.performCreate (Activity.java:8595)
  at android.app.Activity.performCreate (Activity.java:8573)
  at android.app.Instrumentation.callActivityOnCreate (Instrumentation.java:1475)
  at android.app.ActivityThread.performLaunchActivity (ActivityThread.java:3855)
  at android.app.ActivityThread.handleLaunchActivity (ActivityThread.java:4013)
  at android.app.ActivityThread.handleRelaunchActivityInner (ActivityThread.java:6056)
  at android.app.ActivityThread.handleRelaunchActivity (ActivityThread.java:5952)
  at android.app.servertransaction.ActivityRelaunchItem.execute (ActivityRelaunchItem.java:76)
  at android.app.servertransaction.ActivityTransactionItem.execute (ActivityTransactionItem.java:45)
  at android.app.servertransaction.TransactionExecutor.executeCallbacks (TransactionExecutor.java:139)
  at android.app.servertransaction.TransactionExecutor.execute (TransactionExecutor.java:96)
  at android.app.ActivityThread$H.handleMessage (ActivityThread.java:2514)
  at android.os.Handler.dispatchMessage (Handler.java:106)
  at android.os.Looper.loopOnce (Looper.java:232)
  at android.os.Looper.loop (Looper.java:334)
  at android.app.ActivityThread.main (ActivityThread.java:8293)
  at java.lang.reflect.Method.invoke
  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:578)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1053)

Signed-off-by: Marcel Hibbe <[email protected]>
  • Loading branch information
mahibi committed Nov 13, 2024
1 parent 89f3d8a commit 6bf379c
Showing 1 changed file with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,8 @@ class ConversationsListActivity :
conversationsListViewModel = ViewModelProvider(this, viewModelFactory)[ConversationsListViewModel::class.java]

binding = ActivityConversationsBinding.inflate(layoutInflater)

currentUser = userManager.currentUser.blockingGet()
setupActionBar()
setContentView(binding.root)
setupSystemColors()
Expand Down Expand Up @@ -278,7 +280,7 @@ class ConversationsListActivity :
if (!eventBus.isRegistered(this)) {
eventBus.register(this)
}
currentUser = userManager.currentUser.blockingGet()

if (currentUser != null) {
if (isServerEOL(currentUser!!.serverVersion?.major)) {
showServerEOLDialog()
Expand All @@ -296,7 +298,7 @@ class ConversationsListActivity :
fetchRooms()
fetchPendingInvitations()
} else {
Log.e(TAG, "userManager.currentUser.blockingGet() returned null")
Log.e(TAG, "currentUser is null")
Snackbar.make(binding.root, R.string.nc_common_error_sorry, Snackbar.LENGTH_LONG).show()
}

Expand Down Expand Up @@ -762,9 +764,8 @@ class ConversationsListActivity :
)
}

private fun hasActivityActionSendIntent(): Boolean {
return Intent.ACTION_SEND == intent.action || Intent.ACTION_SEND_MULTIPLE == intent.action
}
private fun hasActivityActionSendIntent(): Boolean =
Intent.ACTION_SEND == intent.action || Intent.ACTION_SEND_MULTIPLE == intent.action

private fun showSearchView(searchView: SearchView?, searchItem: MenuItem?) {
binding.conversationListAppbar.stateListAnimator = AnimatorInflater.loadStateListAnimator(
Expand Down Expand Up @@ -1269,10 +1270,9 @@ class ConversationsListActivity :
!participantPermissions.canIgnoreLobby()
}

private fun isReadOnlyConversation(conversation: ConversationModel): Boolean {
return conversation.conversationReadOnlyState ===
private fun isReadOnlyConversation(conversation: ConversationModel): Boolean =
conversation.conversationReadOnlyState ===
ConversationEnums.ConversationReadOnlyState.CONVERSATION_READ_ONLY
}

private fun handleSharedData() {
collectDataFromIntent()
Expand Down

0 comments on commit 6bf379c

Please sign in to comment.