microsoft / EmbeddedSocial-Android-SDK

SDK for interacting with the Microsoft Embedded Social service from inside your Android app
MIT License
9 stars 14 forks source link

NPE in DiscussionFeedFragment.onAttach() #98

Open barbeau opened 6 years ago

barbeau commented 6 years ago

Summary:

I'm seeing two occurrences of this NPE in the Android Developer Console as part of the staged rollout of OneBusAway v2.3.9, which uses 'com.acrowntest.test:sdk:0.7.1:release@aar'.

java.lang.RuntimeException: 
  at android.app.ActivityThread.performLaunchActivity (ActivityThread.java:2778)
  at android.app.ActivityThread.handleLaunchActivity (ActivityThread.java:2856)
  at android.app.ActivityThread.-wrap11 (Unknown Source)
  at android.app.ActivityThread$H.handleMessage (ActivityThread.java:1589)
  at android.os.Handler.dispatchMessage (Handler.java:106)
  at android.os.Looper.loop (Looper.java:164)
  at android.app.ActivityThread.main (ActivityThread.java:6494)
  at java.lang.reflect.Method.invoke (Native Method)
  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:438)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:807)

Caused by: java.lang.NullPointerException: 
  at com.microsoft.embeddedsocial.ui.fragment.DiscussionFeedFragment.onAttach (DiscussionFeedFragment.java:95)
  at android.support.v4.app.Fragment.onAttach (Fragment.java:1340)
  at com.microsoft.embeddedsocial.ui.fragment.base.BaseFragment.onAttach (BaseFragment.java:204)
  at com.microsoft.embeddedsocial.ui.fragment.base.BaseContentFragment.onAttach (BaseContentFragment.java:85)
  at android.support.v4.app.FragmentManagerImpl.moveToState (FragmentManager.java:1372)
  at android.support.v4.app.FragmentTransition.addToFirstInLastOut (FragmentTransition.java:1188)
  at android.support.v4.app.FragmentTransition.calculateFragments (FragmentTransition.java:1071)
  at android.support.v4.app.FragmentTransition.startTransitions (FragmentTransition.java:115)
  at android.support.v4.app.FragmentManagerImpl.executeOpsTogether (FragmentManager.java:2380)
  at android.support.v4.app.FragmentManagerImpl.removeRedundantOperationsAndExecute (FragmentManager.java:2338)
  at android.support.v4.app.FragmentManagerImpl.execPendingActions (FragmentManager.java:2245)
  at android.support.v4.app.FragmentManagerImpl.dispatchStateChange (FragmentManager.java:3248)
  at android.support.v4.app.FragmentManagerImpl.dispatchActivityCreated (FragmentManager.java:3200)
  at android.support.v4.app.FragmentController.dispatchActivityCreated (FragmentController.java:195)
  at android.support.v4.app.FragmentActivity.onStart (FragmentActivity.java:597)
  at android.support.v7.app.AppCompatActivity.onStart (AppCompatActivity.java:177)
  at org.onebusaway.android.ui.ArrivalsListActivity.onStart (ArrivalsListActivity.java:200)
  at android.app.Instrumentation.callActivityOnStart (Instrumentation.java:1334)
  at android.app.Activity.performStart (Activity.java:7029)
  at android.app.ActivityThread.performLaunchActivity (ActivityThread.java:2741)

Steps to reproduce:

Unknown

Expected behavior:

Not crash

Observed behavior:

Crash

Device, Android, and Embedded Social SDK version:

Pixel 2 (walleye) with Android 8.1

'com.acrowntest.test:sdk:0.7.1:release@aar'

acrown-msft commented 6 years ago

Looks like UserAccount.getInstance() is returning null. That should not happen.

The GlobalObjectRegistry must not have a UserAccount object inside. I'll investigate how that happened and consider a fail-safe in the getInstance function that returns a new, unauthenticated, UserAccount.