Skip to content

NPE occurs if account has no localAccountId #669

Closed
@GregDThomas

Description

@GregDThomas

Steps to reproduce

Expected results

  • New token is generated, and then re-used as it's in the cache

Actual results

  • New token is generated, then an NPE occurs as there is no localAccountId and the following statement throws an NPE;
    • if (accCached.homeAccountId().contains(accCached.localAccountId())) {
==No accounts in cache
17:46:47.494 [ForkJoinPool.commonPool-worker-3] DEBUG com.microsoft.aad.msal4j.PublicClientApplication - [Correlation ID: cd8843c4-5fc5-4d42-9d65-e6e7675f042b] Execution of class com.microsoft.aad.msal4j.AcquireTokenSilentSupplier failed.
com.microsoft.aad.msal4j.MsalClientException: Token not found in the cache
	at com.microsoft.aad.msal4j.AcquireTokenSilentSupplier.execute(AcquireTokenSilentSupplier.java:75)
	at com.microsoft.aad.msal4j.AuthenticationResultSupplier.get(AuthenticationResultSupplier.java:69)
	at com.microsoft.aad.msal4j.AuthenticationResultSupplier.get(AuthenticationResultSupplier.java:18)
	at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1700)
	at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.exec(CompletableFuture.java:1692)
	at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)
	at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020)
	at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656)
	at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594)
	at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:183)
==acquireTokenSilently call failed: com.microsoft.aad.msal4j.MsalClientException: Token not found in the cache
17:46:47.565 [ForkJoinPool.commonPool-worker-3] DEBUG com.microsoft.aad.msal4j.TokenRequestExecutor - Sending token request to: https://adfs.mbtest.bt.com/adfs/
17:46:48.867 [ForkJoinPool.commonPool-worker-3] DEBUG com.microsoft.aad.msal4j.PublicClientApplication - [Correlation ID: 48f8b765-57e0-44b6-8325-20d9f97b2272] Access Token and Refresh Token were returned
==username/password flow succeeded
Account username: **REDACTED** 
Access token:     **REDACTED** 
Id token:         **REDACTED** 

17:46:48.882 [ForkJoinPool.commonPool-worker-3] ERROR com.microsoft.aad.msal4j.PublicClientApplication - [Correlation ID: 865566e9-a1d5-444f-b364-976f46a9b953] Execution of class com.microsoft.aad.msal4j.AccountsSupplier failed.
java.lang.NullPointerException: null
	at java.base/java.lang.String.contains(String.java:2036)
	at com.microsoft.aad.msal4j.TokenCache.getAccounts(TokenCache.java:349)
	at com.microsoft.aad.msal4j.AccountsSupplier.get(AccountsSupplier.java:26)
	at com.microsoft.aad.msal4j.AccountsSupplier.get(AccountsSupplier.java:11)
	at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1700)
	at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.exec(CompletableFuture.java:1692)
	at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)
	at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020)
	at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656)
	at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594)
	at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:183)

Metadata

Metadata

Assignees

Labels

BugSomething isn't working, needs an investigation and a fixRequires more infoMore information is needed, from either the person who opened the issue or another teampublic-clientFor questions/issues related to public client apps

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions