Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Number format exception Transfer Record #1461

Closed
sougandhmp opened this issue Jan 30, 2020 · 25 comments
Closed

Number format exception Transfer Record #1461

sougandhmp opened this issue Jan 30, 2020 · 25 comments
Assignees
Labels
bug Something isn't working pending-community-response Issue is pending response from the issue requestor s3 Issues with the AWS Android SDK for Simple Storage Service (S3).

Comments

@sougandhmp
Copy link

sougandhmp commented Jan 30, 2020

Sharing the crash logs

AWS s3 transfer utility causes crash. Have seen similar bug
#1093 in which it was suggested to remove "awss3transfertable.db"which i have not tried. But I have tried updating to the latest version but still issues are reported..

Caused by java.lang.NumberFormatException
For input string: "ANY"

sun.misc.FloatingDecimal.readJavaFormatString (FloatingDecimal.java:2043)
sun.misc.FloatingDecimal.parseDouble (FloatingDecimal.java:110)
java.lang.Double.parseDouble (Double.java:538)
com.google.gson.stream.JsonReader.nextInt (JsonReader.java:186)
com.google.gson.internal.bind.TypeAdapters$7.a (TypeAdapters.java:13)
com.google.gson.internal.bind.TypeAdapters$7.read (TypeAdapters.java)
com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.a (ReflectiveTypeAdapterFactory.java:2)
com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.a (ReflectiveTypeAdapterFactory.java:47)
com.google.gson.Gson.a (Gson.java:20)
com.google.gson.Gson.a (Gson.java:4)
com.google.gson.Gson.a (Gson.java:9)
com.google.gson.Gson.assertFullConsumption (Gson.java)

com.amazonaws.mobileconnectors.s3.transferutility.TransferRecord.a (TransferRecord.java:422)
com.amazonaws.mobileconnectors.s3.transferutility.TransferDBUtil.getTransferById (TransferDBUtil.java:16)
com.amazonaws.mobileconnectors.s3.transferutility.TransferUtility.a (TransferUtility.java:20)
com.amazonaws.mobileconnectors.s3.transferutility.TransferUtility.a (TransferUtility.java:2)
com.amazonaws.mobileconnectors.s3.transferutility.TransferUtility.a (TransferUtility.java:23)

  • AWS Android SDK Version: [e.g. 2.16.6, older versions also]
  • Device: [e.g. Galaxy S9 and many devices]
  • Android Version: [9]
@raphkim
Copy link
Contributor

raphkim commented Jan 31, 2020

Hi @sougandhmp ,

There may be a potential issue with how GSON de/serializes TransferNetworkConnectionType in the Android SDK for S3 when the code is obfuscated. Would you be able to try modifying your proguard configuration as following?

@raphkim raphkim added bug Something isn't working s3 Issues with the AWS Android SDK for Simple Storage Service (S3). labels Jan 31, 2020
@raphkim raphkim self-assigned this Jan 31, 2020
@sougandhmp
Copy link
Author

Hi @raphkim,
Thanks for the suggestion, I have added -keepclassmembers enum * { *; } to the proguard rules. I will be checking crash is happening again for this reason.

@raphkim raphkim added the closing soon Issue will auto-close if there is no additional activity within 7 days. label Feb 7, 2020
@sougandhmp
Copy link
Author

sougandhmp commented Feb 10, 2020

Hi @raphkim ,

Is there something that can be done, other than adding "-keepclassmembers enum * { *; } " to pro-guard rules?.Please note the issue was not reported for fresh users. Further more, the issue seems to recur for specific users.

Any help would be appreciated.

@stale stale bot removed the closing soon Issue will auto-close if there is no additional activity within 7 days. label Feb 10, 2020
@raphkim
Copy link
Contributor

raphkim commented Feb 12, 2020

Have you tried deleting "awss3transfertable.db"? If the issue is only recurring for some people, I think it may be possible for the database to be corrupted.

@palpatim palpatim added the pending-community-response Issue is pending response from the issue requestor label Feb 14, 2020
@sougandhmp
Copy link
Author

Hi @raphkim , @palpatim

I have not tried deleting "awss3transfertable.db". I have already mentioned it in the description of bug.
Since the issue was only happening for few production users i was not able to reproduce and check the issue.

@raphkim
Copy link
Contributor

raphkim commented Feb 19, 2020

I would suggest clearing the transfer database before moving forward. Once the database is corrupted, the issue will persist as long as the app continues to access it.

@svanegas
Copy link

svanegas commented Mar 2, 2020

@sougandhmp, did you try deleting the "awss3transfertable.db"? any updates on your end?

@raphkim. I'm having the same issue and I'm not using obfuscation. Here's the stacktrace:

Caused by java.lang.NumberFormatException: Invalid double: "ANY"
       at java.lang.StringToReal.invalidReal(StringToReal.java:63)
       at java.lang.StringToReal.initialParse(StringToReal.java:164)
       at java.lang.StringToReal.parseDouble(StringToReal.java:282)
       at java.lang.Double.parseDouble(Double.java:301)
       at com.google.gson.stream.JsonReader.nextInt(JsonReader.java:1201)
       at com.google.gson.internal.bind.TypeAdapters$7.read(TypeAdapters.java:226)
       at com.google.gson.internal.bind.TypeAdapters$7.read(TypeAdapters.java:218)
       at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.read(ReflectiveTypeAdapterFactory.java:131)
       at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:222)
       at com.google.gson.Gson.fromJson(Gson.java:927)
       at com.google.gson.Gson.fromJson(Gson.java:892)
       at com.google.gson.Gson.fromJson(Gson.java:841)
       at com.google.gson.Gson.fromJson(Gson.java:813)
       at com.amazonaws.mobileconnectors.s3.transferutility.TransferRecord.updateFromDB(TransferRecord.java:159)
       at com.amazonaws.mobileconnectors.s3.transferutility.TransferDBUtil.getTransferById(TransferDBUtil.java:865)
       at com.amazonaws.mobileconnectors.s3.transferutility.TransferUtility.submitTransferJob(TransferUtility.java:901)
       at com.amazonaws.mobileconnectors.s3.transferutility.TransferUtility.pause(TransferUtility.java:772)
       at com.amazonaws.mobileconnectors.s3.transferutility.TransferUtility.pauseAllWithType(TransferUtility.java:787)

SDK Version: 2.16.5
Noticed that happens mostly on Samsung devices with Android 10

Since I can't reproduce either, do you have some idea how this can be reproducible? Furthermore, about deleting the "awss3transfertable.db":

  • Could you please specify how should this process be done?
  • When exactly needs to be deleted?
  • Wouldn't it affect anything else in the schema?

Thanks

@sougandhmp
Copy link
Author

Hi @svanegas,

No I couldn't verify the solution since I was not able to reproduce the crash.

@desokroshan desokroshan added the closing soon Issue will auto-close if there is no additional activity within 7 days. label Apr 3, 2020
@svanegas
Copy link

svanegas commented Apr 15, 2020

@TrekSoft, @desokroshan, @palpatim, @raphkim. Guys, I'm still facing this issue and it's becoming now a big deal in production. Could anyone please assign to corresponding person and reopen this ticket?

Stack trace is above, and as I mentioned, occurs mostly on Samsung devices with Android 10.

Could you please explain me how could I implement a workaround or solve this issue?

Thanks

@raphkim raphkim reopened this Apr 15, 2020
@stale stale bot removed the closing soon Issue will auto-close if there is no additional activity within 7 days. label Apr 15, 2020
@raphkim
Copy link
Contributor

raphkim commented Apr 15, 2020

Hi @svanegas ,

I apologize for pre-maturely closing the issue. It seems to me that most people that have experienced this issue were able to resolve their issue by deleting their in-memory transfer data "awss3transfertable.db". This is the database that stores all of the ongoing transfers in the app so that the information is not lost upon closing the app.

This database can be deleted by using Context#deleteDatabase(String) method and using "awss3transfertable.db" as the argument. However, I would advise against using this regularly inside the app outside of the context of explicitly clearing data.

I will further investigate the issue to see what we can do to mitigate the corruption of database.

@raphkim
Copy link
Contributor

raphkim commented Apr 15, 2020

@svanegas would you be able to check if you have minifyEnabled set to true inside your build.gradle file?

@svanegas
Copy link

@raphkim. Thank you for reply.

Yes, minifyEnabled is true.

I was getting ready to release soon a prod version that uses deleteDatabase("awss3transfertable.db") in the onCreate() of the Application class as a temporary workaround. But then I saw that you advise against using it this way.

Do you think the deletion of the database every time app is opened would affect something else? What do you think could be done better?

@raphkim
Copy link
Contributor

raphkim commented Apr 15, 2020

For future reference, minifyEnabled = true will obfuscate your code ;)

Deleting the database in the onCreate() method would remove the transfer information every time the app is exited, which defeats the purpose of keeping a persistent record of the ongoing transfers. This issue should ideally be resolved once the corrupted table is deleted once (outside of the app's lifecycle), and should not require it to be deleted thereafter.

@svanegas
Copy link

For future reference, minifyEnabled = true will obfuscate your code ;)

Deleting the database in the onCreate() method would remove the transfer information every time the app is exited, which defeats the purpose of keeping a persistent record of the ongoing transfers. This issue should ideally be resolved once the corrupted table is deleted once (outside of the app's lifecycle), and should not require it to be deleted thereafter.

@raphkim. Okay, so do you think a good strategy would be: Catch this exception, when this happens, delete database. It might be enough, right?

@raphkim
Copy link
Contributor

raphkim commented Apr 16, 2020

There may be a potential issue with how GSON de/serializes TransferNetworkConnectionType in the Android SDK for S3 when the code is obfuscated. Would you be able to try modifying your proguard configuration as following?

While deleting database upon gson failure would be a good temporary workaround, I suggest that you verify the above solution first for a more permanent solution. With the temporary solution you've provided, a user experiencing this issue will inexplicably lose data on all of the ongoing/past transfers

@raphkim raphkim self-assigned this Apr 16, 2020
@raphkim raphkim closed this as completed Apr 16, 2020
@svanegas
Copy link

svanegas commented Apr 16, 2020

Thanks @raphkim.

I already had this config, actually:

-keepnames class com.amazonaws.**
-keepnames class com.amazon.**

We will see how it behaves with database deletion workaround!

@raphkim
Copy link
Contributor

raphkim commented Apr 16, 2020

Here is the full config that you should use when enabling proguard:
https://github.com/aws-amplify/aws-sdk-android/blob/master/Proguard.md

Also -keepclassmembers enum * { *; } would be the required config to resolve this particular issue.

@buntupana
Copy link

buntupana commented Nov 3, 2022

After more than two year this issue is still happening sometimes. Is there any solution to prevent this happening?

@AnupPorter
Copy link

AnupPorter commented Dec 8, 2022

@raphkim
How is the database getting corrupt in the first place? This might happen again in the future, and I need to identify it.

@PruthvirajSoftvan
Copy link

PruthvirajSoftvan commented Dec 13, 2022

I have faced an issue after updating aws SDK from 2.28.0 to 2.58.0

Fatal Exception: com.google.gson.n: java.lang.NumberFormatException: For input string: "ANY"
       at com.google.gson.internal.bind.TypeAdapters$7.b(TypeAdapters.java:25)
       at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.read(ReflectiveTypeAdapterFactory.java:2)
       at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:47)
       at com.google.gson.Gson.fromJson(Gson.java:31)
       at com.google.gson.Gson.b(Gson.java:1)
       at com.amazonaws.mobileconnectors.s3.transferutility.TransferRecord.updateFromDB(TransferRecord.java:422)
       at com.amazonaws.mobileconnectors.s3.transferutility.TransferNetworkLossHandler.resumeAllTransfersOnNetworkAvailability(TransferNetworkLossHandler.java:73)
       at com.amazonaws.mobileconnectors.s3.transferutility.TransferNetworkLossHandler$1.run(TransferNetworkLossHandler.java:73)
       at java.lang.Thread.run(Thread.java:1012)

Update Aws SDK from 2.28.0 to 2.58.0
Also added poguard rules which is already disccus in above conversation but still issue was show in firabse crashlytics.

Refer to above conversation and following steps deleted by using Context#deleteDatabase(String) method so my question is that affect any other schema or internal app database or any change to crash end user or client app at production?

@mquineche
Copy link

I'm facing this issue.
I updated AWS SDK from 2.13.7 to 2.62.2.
From Crashltycs: 5k crash events in 5 users

Fatal Exception: com.google.gson.JsonSyntaxException: java.lang.NumberFormatException: For input string: "ANY" at com.google.gson.internal.bind.TypeAdapters$11.read(TypeAdapters.java:307) at com.google.gson.internal.bind.TypeAdapters$11.read(TypeAdapters.java:297) at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.read(ReflectiveTypeAdapterFactory.java:131) at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:222) at com.google.gson.Gson.fromJson(Gson.java:963) at com.google.gson.Gson.fromJson(Gson.java:928) at com.google.gson.Gson.fromJson(Gson.java:877) at com.google.gson.Gson.fromJson(Gson.java:848) at com.amazonaws.mobileconnectors.s3.transferutility.TransferRecord.updateFromDB(TransferRecord.java:159) at com.amazonaws.mobileconnectors.s3.transferutility.TransferNetworkLossHandler.resumeAllTransfersOnNetworkAvailability(TransferNetworkLossHandler.java:176) at com.amazonaws.mobileconnectors.s3.transferutility.TransferNetworkLossHandler.access$000(TransferNetworkLossHandler.java:37) at com.amazonaws.mobileconnectors.s3.transferutility.TransferNetworkLossHandler$1.run(TransferNetworkLossHandler.java:123) at java.lang.Thread.run(Thread.java:919)

So any of those workaround has fixed this particular issue ?

@buntupana
Copy link

And still no official answer

@buntupana
Copy link

buntupana commented Apr 7, 2023

@raphkim I'm still experiencing this issue once in a while for some production users and I can't even catch it to avoid crash and delete the database as it's suggested so I have no real solution.

@sdhuka sdhuka reopened this Apr 7, 2023
@sdhuka sdhuka assigned sdhuka and unassigned raphkim Apr 7, 2023
@sdhuka
Copy link
Contributor

sdhuka commented Apr 7, 2023

@buntupana We have reopened the issue and investigate further.

@sdhuka
Copy link
Contributor

sdhuka commented Jun 20, 2023

@buntupana We have added the fix to prevent the crash in case of deserialization exception. Please update to the latest sdk version for the fix.

@sdhuka sdhuka closed this as completed Jun 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working pending-community-response Issue is pending response from the issue requestor s3 Issues with the AWS Android SDK for Simple Storage Service (S3).
Projects
None yet
Development

No branches or pull requests

10 participants