SAP/gigya-android-sdk

IllegalStateException on loading cached account with invalid scheme

Closed this issue · 2 comments

SDK library: core

Preconditions:

  • Having an account scheme that is send by the backend
  • Having an incompatible account scheme on the client
  • Caching on the client sdk is enabled

Action:
Request an account via Gigya.getAccount() on the client

Expected Result:
Because the local scheme does not match the remote scheme get an error via GigyaCallback.onError()

Actual Result:
IllegalStateException thrown out of the Gigya.getAccount() call.

com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was BEGIN_ARRAY at path $.data.loyalty
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:397)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.readIntoField(ReflectiveTypeAdapterFactory.java:212)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$FieldReflectionAdapter.readField(ReflectiveTypeAdapterFactory.java:433)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:393)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.readIntoField(ReflectiveTypeAdapterFactory.java:212)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$FieldReflectionAdapter.readField(ReflectiveTypeAdapterFactory.java:433)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:393)
at com.google.gson.Gson.fromJson(Gson.java:1227)
at com.google.gson.Gson.fromJson(Gson.java:1329)
at com.google.gson.Gson.fromJson(Gson.java:1300)
at com.gigya.android.sdk.utils.AccountGSONDeserializer.deserialize(AccountGSONDeserializer.java:33)
at com.google.gson.internal.bind.TreeTypeAdapter.read(TreeTypeAdapter.java:76)
at com.google.gson.Gson.fromJson(Gson.java:1227)
at com.google.gson.Gson.fromJson(Gson.java:1137)
at com.google.gson.Gson.fromJson(Gson.java:1047)
at com.google.gson.Gson.fromJson(Gson.java:982)
at com.gigya.android.sdk.account.accountCacheService.getAccount(accountCacheService.java:72)
at com.gigya.android.sdk.api.BusinessApiService.getAccount(BusinessApiService.java:535)
at com.gigya.android.sdk.Gigya.getAccount(Gigya.java:564)

Reason:

The response is cached although it was not parsed successfully. Trying to read it from the cache later fails again, because the local scheme still does not match the remote scheme.

screenshot

Question:

Can this be fixed? When?
Thx ✌️

tal-mi commented

I will take care of this in the next version.

Fixed in v7.0.7