[google_sign_in_android] Fix IllegalStateException on duplicate authorization result#11984
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
11f23f9 to
53bf0ed
Compare
There was a problem hiding this comment.
Code Review
This pull request updates the Android implementation of the google_sign_in plugin to prevent an IllegalStateException crash caused by duplicate activity results. In GoogleSignInPlugin.java, the pendingAuthorizationCallback is now cleared before it is resolved, ensuring that a re-delivered result does not complete the callback twice. A regression test has been added to verify that duplicate results are ignored, and the package version is bumped to 7.2.14. There are no review comments, and I have no feedback to provide.
|
@googlebot I signed it! |
…rization result
Delegate.onActivityResult resolved the authorization callback on its success
path and returned before clearing pendingAuthorizationCallback (which only
happened on the ApiException path). A re-delivered activity result for
REQUEST_CODE_AUTHORIZE (e.g. after a configuration change or process death)
then completed the same Pigeon Reply twice, throwing IllegalStateException
("Reply already submitted").
Capture the callback and null the field before completing it, so any
duplicate/late delivery falls through to the "Unexpected authorization result
callback" branch. Adds a regression test.
Fixes flutter/flutter#188062
53bf0ed to
ad4c575
Compare
google_sign_in_android'sGoogleSignInPlugin.Delegate.onActivityResultresolved the pending authorization callback on its success path and returnedtruebefore clearingpendingAuthorizationCallback— that field was only nulled on theApiException(failure) path. As a result, when theREQUEST_CODE_AUTHORIZEactivity result is delivered more than once (for example when a saved result is re-delivered after a configuration change or process death), the method re-enters with the field still set and completes the same PigeonReplya second time, throwing:This change captures the callback into a local and nulls
pendingAuthorizationCallbackbefore completing it, so any duplicate or late delivery for the same request code falls through to the existing"Unexpected authorization result callback"branch instead of double-completing the reply. The existing success/failure return semantics are unchanged.A regression test (
authorize_ignoresDuplicateActivityResult) drives the authorize → success flow, invokesonActivityResulttwice, and asserts the callback is resolved exactly once and the second delivery is not consumed. It fails before this change and passes after.Issues fixed by this PR
Fixes flutter/flutter#188062
Notes
google-java-formatv1.28.0) on the changed Java — no changes needed.google_sign_in_androidAndroid unit tests pass locally viatestDebugUnitTest, including the new regression test.Pre-Review Checklist
[shared_preferences]///).Footnotes
Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling. ↩ ↩2