Skip to content
This repository has been archived by the owner on Apr 15, 2023. It is now read-only.

Fix currentActivity null pointer exception #40

Merged
merged 1 commit into from
Jun 9, 2017
Merged

Fix currentActivity null pointer exception #40

merged 1 commit into from
Jun 9, 2017

Conversation

AndrewJack
Copy link
Contributor

@AndrewJack AndrewJack commented Jun 1, 2017

Seeing a lot of crashes on crashlytics:

Fatal Exception: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Class java.lang.Object.getClass()' on a null object reference
       at com.reactNativeQuickActions.AppShortcutsModule.setShortcutItems(AppShortcutsModule.java:102)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.facebook.react.bridge.BaseJavaModule$JavaMethod.invoke(BaseJavaModule.java:368)
       at com.facebook.react.cxxbridge.JavaModuleWrapper.invoke(JavaModuleWrapper.java:138)
       at com.facebook.react.bridge.queue.NativeRunnable.run(NativeRunnable.java)
       at android.os.Handler.handleCallback(Handler.java:751)
       at android.os.Handler.dispatchMessage(Handler.java:95)
       at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:31)
       at android.os.Looper.loop(Looper.java:154)
       at com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run(MessageQueueThreadImpl.java:208)
       at java.lang.Thread.run(Thread.java:761)

getCurrentActivity() is @Nullable so we should check.

Guessing the method was called at the same time the app was closing.

Thanks in advance @jordanbyron

@AndrewJack
Copy link
Contributor Author

Hi @jordanbyron do you have time to release this?

This should be the last of the issues 😄

Thanks.

@jordanbyron
Copy link
Owner

jordanbyron commented Jun 7, 2017

Hey @AndrewJack!

I'll have time on Friday to take a look at this. Could you give me steps to reproduce the error you are fixing so I can verify this PR fixes them.

Thanks!

Jordan

@AndrewJack
Copy link
Contributor Author

Steps:

  1. call setShortcutItems
  2. Press back immediately after

Actual: Will crash with exception above
Expected: Doesn't crash if activity has been destroyed.

It's a tough one to reproduce because you have to time it perfectly, but it happens fairy frequently in the wild.

@jordanbyron jordanbyron merged commit c5c4084 into jordanbyron:master Jun 9, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants