forcedotcom / SalesforceMobileSDK-Android

Android SDK for Salesforce
Other
341 stars 388 forks source link

Crash caused by Okhttp interceptor being set to null by RestClient. #2620

Closed adriduttaheb closed 1 month ago

adriduttaheb commented 1 month ago

Please fill out the following details:

  1. Version of Mobile SDK Used: 12.0.0
  2. Issue found in Native App or Hybrid App: Native App
  3. OS Version: Any
  4. Device: Any
  5. Steps to reproduce: Opening the native app from background.
  6. Actual behavior: App crashes
  7. Expected Behavior: App doesn't crash.
  8. Error Log:
          Fatal Exception: java.lang.IllegalStateException: Null interceptor: [null, com.salesforce.androidsdk.rest.RestClient$OAuthRefreshInterceptor@98f2dde]
       at okhttp3.OkHttpClient.verifyClientState(OkHttpClient.kt:248)
       at okhttp3.OkHttpClient.<init>(OkHttpClient.kt:244)
       at okhttp3.OkHttpClient$Builder.build(OkHttpClient.kt:1069)
       at com.salesforce.androidsdk.rest.RestClient.setOkHttpClient(RestClient.java:235)
       at com.salesforce.androidsdk.rest.RestClient.<init>(RestClient.java:146)
       at com.salesforce.androidsdk.rest.ClientManager.peekRestClient(ClientManager.java:295)
       at com.salesforce.androidsdk.rest.ClientManager.peekRestClient(ClientManager.java:161)
       at com.salesforce.androidsdk.rest.ClientManager.getRestClient(ClientManager.java:138)
       at com.salesforce.androidsdk.ui.SalesforceActivityDelegate.onResume(SalesforceActivityDelegate.java:91)

Seems like in RestClient.java there is one global oAuthInterceptor, that is set by setOAuthRefreshInterceptor() so I am really confused on how there can be a list of interceptors as shown in the error log.

Thanks!

wmathurin commented 1 month ago

This issue is fixed in the latest version of Mobile SDK (12.1.1). See PR.