Muljin / msal-flutter

BSD 3-Clause "New" or "Revised" License
9 stars 37 forks source link

Fix empty list exception #10

Open lngyeen opened 2 years ago

lngyeen commented 2 years ago

java.util.NoSuchElementException: List is empty. at kotlin.collections.CollectionsKt___CollectionsKt.first(_Collections.kt:212) at uk.co.moodio.msal_flutter.MsalFlutterPlugin.clearAccounts(MsalFlutterPlugin.kt:157)

mswehli commented 2 years ago

Hi @lngyeen thanks for the PR. Can you give a bit more context in when you got the exception? As we already check to make sure the account list is not empty with the any() function call, so the issue might be caused by something else such as parallel calls

lngyeen commented 2 years ago

@mswehli The exception occurred when I try to sign out right after signing in, not always but sometimes. Another point is, take a look at msalApp.accounts, you can see that is a computed property (not stored property), that mean the msalApp.account on line 156 may be different from line 157.