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

Fixed bug in handleStopListeningAuthState method #620

Merged
merged 3 commits into from
Jul 2, 2018
Merged

Fixed bug in handleStopListeningAuthState method #620

merged 3 commits into from
Jul 2, 2018

Conversation

Noble-Mushtak
Copy link
Contributor

The following refers to variables used in FirebaseAuthPlugin.java. Basically, authStateListeners.removeAt(id) was changed to authStateListeners.remove(id).

Here, id is a key corresponding to listener in the SparseArray. Since id is a key, not an index, remove() should be used instead of removeAt(). Otherwise, out-of-bounds exceptions may occur, such as the following error that occurred after a subscription was canceled to onAuthStateChanged in a Flutter app I am working on:

E/MethodChannel#plugins.flutter.io/firebase_auth( 2008): Failed to handle method call
E/MethodChannel#plugins.flutter.io/firebase_auth( 2008): java.lang.ArrayIndexOutOfBoundsException: length=13; index=13
E/MethodChannel#plugins.flutter.io/firebase_auth( 2008): 	at android.util.SparseArray.removeAt(SparseArray.java:147)
E/MethodChannel#plugins.flutter.io/firebase_auth( 2008): 	at io.flutter.plugins.firebaseauth.FirebaseAuthPlugin.handleStopListeningAuthState(FirebaseAuthPlugin.java:351)
E/MethodChannel#plugins.flutter.io/firebase_auth( 2008): 	at io.flutter.plugins.firebaseauth.FirebaseAuthPlugin.onMethodCall(FirebaseAuthPlugin.java:111)
E/MethodChannel#plugins.flutter.io/firebase_auth( 2008): 	at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:191)
E/MethodChannel#plugins.flutter.io/firebase_auth( 2008): 	at io.flutter.view.FlutterNativeView.handlePlatformMessage(FlutterNativeView.java:136)
E/MethodChannel#plugins.flutter.io/firebase_auth( 2008): 	at android.os.MessageQueue.nativePollOnce(Native Method)
E/MethodChannel#plugins.flutter.io/firebase_auth( 2008): 	at android.os.MessageQueue.next(MessageQueue.java:143)
E/MethodChannel#plugins.flutter.io/firebase_auth( 2008): 	at android.os.Looper.loop(Looper.java:122)
E/MethodChannel#plugins.flutter.io/firebase_auth( 2008): 	at android.app.ActivityThread.main(ActivityThread.java:5254)
E/MethodChannel#plugins.flutter.io/firebase_auth( 2008): 	at java.lang.reflect.Method.invoke(Native Method)
E/MethodChannel#plugins.flutter.io/firebase_auth( 2008): 	at java.lang.reflect.Method.invoke(Method.java:372)
E/MethodChannel#plugins.flutter.io/firebase_auth( 2008): 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
E/MethodChannel#plugins.flutter.io/firebase_auth( 2008): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)

Copy link
Contributor

@mravn-google mravn-google left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fix. Please bump the version in pubspec.yaml and add a CHANGELOG.md entry.

@mravn-google mravn-google self-assigned this Jun 26, 2018
@Hixie
Copy link
Contributor

Hixie commented Jun 26, 2018

cc @kroikie for review

Copy link
Contributor

@mravn-google mravn-google left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@mravn-google mravn-google merged commit 5c19815 into flutter:master Jul 2, 2018
@mravn-google
Copy link
Contributor

New version published.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants