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

com.squareup.moshi.JsonDataException: Expected an int but was .... #236

Closed
andrasferenczi opened this issue Mar 6, 2018 · 1 comment
Closed
Labels

Comments

@andrasferenczi
Copy link

andrasferenczi commented Mar 6, 2018

I've found this very rare error and I did not see it posted as an issue.

I compiled with the latest commit: 25bd4a4

Error:

[1 ->] GET https://oauth.reddit.com/r/MisleadingPuddles/new?limit=100&sort=new&raw_json=1
[<- 1] 200 application/json: '{"kind": "Listing", "data": {"after": "t3_3flxcj", "dist": 100, "modhash": null, "whitelist_status": null, "children": [{"kind": "t3", "data": {"domain": "i.imgur.co(...)
Exception in thread "main" com.squareup.moshi.JsonDataException: Expected an int but was 3153600000 at path $.data.children[82].data.secure_media.oembed.cache_age
	at com.squareup.moshi.JsonUtf8Reader.nextInt(JsonUtf8Reader.java:853)
	at com.squareup.moshi.StandardJsonAdapters$7.fromJson(StandardJsonAdapters.java:163)
	at com.squareup.moshi.StandardJsonAdapters$7.fromJson(StandardJsonAdapters.java:161)
	at com.squareup.moshi.JsonAdapter$2.fromJson(JsonAdapter.java:128)
	at com.squareup.moshi.JsonAdapter$2.fromJson(JsonAdapter.java:128)
	at net.dean.jraw.models.AutoValue_EmbeddedMedia_OEmbed$MoshiJsonAdapter.fromJson(AutoValue_EmbeddedMedia_OEmbed.java:102)
	at net.dean.jraw.models.AutoValue_EmbeddedMedia_OEmbed$MoshiJsonAdapter.fromJson(AutoValue_EmbeddedMedia_OEmbed.java:18)
	at com.squareup.moshi.JsonAdapter$2.fromJson(JsonAdapter.java:128)
	at net.dean.jraw.models.AutoValue_EmbeddedMedia$MoshiJsonAdapter.fromJson(AutoValue_EmbeddedMedia.java:44)
	at net.dean.jraw.models.AutoValue_EmbeddedMedia$MoshiJsonAdapter.fromJson(AutoValue_EmbeddedMedia.java:17)
	at com.squareup.moshi.JsonAdapter$2.fromJson(JsonAdapter.java:128)
	at net.dean.jraw.models.AutoValue_Submission$MoshiJsonAdapter.fromJson(AutoValue_Submission.java:219)
	at net.dean.jraw.models.AutoValue_Submission$MoshiJsonAdapter.fromJson(AutoValue_Submission.java:30)
	at net.dean.jraw.models.internal.AutoValue_RedditModelEnvelope$MoshiJsonAdapter.fromJson(AutoValue_RedditModelEnvelope.java:38)
	at net.dean.jraw.models.internal.AutoValue_RedditModelEnvelope$MoshiJsonAdapter.fromJson(AutoValue_RedditModelEnvelope.java:17)
	at com.squareup.moshi.JsonAdapter$2.fromJson(JsonAdapter.java:128)
	at net.dean.jraw.databind.RedditModelAdapterFactory$StaticAdapter.fromJson(RedditModelAdapterFactory.kt:112)
	at com.squareup.moshi.JsonAdapter$2.fromJson(JsonAdapter.java:128)
	at net.dean.jraw.databind.RedditModelAdapterFactory$ListingAdapter.readListing(RedditModelAdapterFactory.kt:197)
	at net.dean.jraw.databind.RedditModelAdapterFactory$ListingAdapter.fromJson(RedditModelAdapterFactory.kt:168)
	at net.dean.jraw.databind.RedditModelAdapterFactory$ListingAdapter.fromJson(RedditModelAdapterFactory.kt:154)
	at com.squareup.moshi.JsonAdapter.fromJson(JsonAdapter.java:35)
	at com.squareup.moshi.JsonAdapter.fromJson(JsonAdapter.java:39)
	at net.dean.jraw.http.HttpResponse.deserializeWith(HttpResponse.kt:49)
	at net.dean.jraw.pagination.Paginator.next(Paginator.kt:66)
	at net.dean.jraw.pagination.Paginator$iterator$1.next(Paginator.kt:80)
	at net.dean.jraw.pagination.Paginator$iterator$1.next(Paginator.kt:78)
	...

Edit.: If it helps you in any way, here is the link to the post

@mattbdean mattbdean added the bug label Mar 11, 2018
@mattbdean
Copy link
Owner

Signed 32-bit integers store a maximum value of ~2 billion, but the value in question is 3.1 billion. The fix here is to just change the type of EmbeddedMedia.getCacheAge() to Long

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants