-
Notifications
You must be signed in to change notification settings - Fork 48
Open
Description
Hello,
I think I found a race condition in your code:
- Invoking the
com.microsoft.identity.client.PublicClientApplication.create(android.content.Context, String, String, String, com.microsoft.identity.client.IPublicClientApplication.ApplicationCreatedListener)method leads to invocationscom.microsoft.identity.common.java.authorities.Authority.getEquivalentConfiguredAuthority([...])com.microsoft.identity.common.java.authorities.Authority.addKnownAuthorities([...])
- These invocations can occur in different threads, because
com.microsoft.identity.client.PublicClientApplication.create([...])spawns a new thread on each invocation. - While
getEquivalentConfiguredAuthorityiterates over thejava.util.ArrayList knownAuthoritiesinstance,addKnownAuthoritiesinserts elements in the same instance. (knownAuthoritiesis definedstatic final.) - There is no (effective) synchronization to sequentialize the order of both calls. Hence, iteration and insertion can occur concurrently. This is not supported by
java.util.ArrayList. Hence, there is a race condition. With some chance, ajava.util.ConcurrentModificationExceptionoccurs.
Maybe you want to investigate this, if this is not the intended behavior.
Regards, Luis.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels