Trying to use Twitter Stream Stream. When parsing stream buffer response with FilteredStreamingTweet.fromJson got this error :
com.google.gson.JsonSyntaxException: java.io.IOException: Failed deserialization for FilteredStreamingTweet: 2 classes match result, expected 1. (Full log at the end)
Expected behavior
When using FilteredStreamingTweet.fromJson, expecing to have most of the response parsed
Actual behavior
Failing
Steps to reproduce the behavior
Get HelloWorldStreaming example,
Replace sample stream to have a valid search stream
Replace StreamingTweetto FilteredStreamingTweet
Run the example.
Extra data
Full log dump
com.google.gson.JsonSyntaxException: java.io.IOException: Failed deserialization for FilteredStreamingTweet: 2 classes match result, expected 1. JSON: {"data":{"attachments":{"media_keys":["3_1529016941515378688","3_1529016942450774021"]},"author_id":"2354994440","created_at":"2022-05-24T08:30:23.000Z","entities":{"mentions":[{"start":0,"end":12,"username":"taegiveaway","id":"1353847968919547904"},{"start":13,"end":26,"username":"ZelenskiyNFT","id":"1509950611483156488"}],"urls":[{"start":41,"end":64,"url":"https://t.co/sT4XPjBilR","expanded_url":"https://twitter.com/seokshuu/status/1529016950554099713/photo/1","display_url":"pic.twitter.com/sT4XPjBilR","media_key":"3_1529016941515378688"},{"start":41,"end":64,"url":"https://t.co/sT4XPjBilR","expanded_url":"https://twitter.com/seokshuu/status/1529016950554099713/photo/1","display_url":"pic.twitter.com/sT4XPjBilR","media_key":"3_1529016942450774021"}]},"geo":{},"id":"1529016950554099713","in_reply_to_user_id":"1353847968919547904","lang":"en","referenced_tweets":[{"type":"replied_to","id":"1527450748275290112"}],"text":"@taegiveaway @ZelenskiyNFT acc suspended https://t.co/sT4XPjBilR"},"includes":{"media":[{"media_key":"3_1529016941515378688","type":"photo","url":"https://pbs.twimg.com/media/FTgozqaUEAAhmgJ.jpg"},{"media_key":"3_1529016942450774021","type":"photo","url":"https://pbs.twimg.com/media/FTgozt5VEAU9qVA.jpg"}],"users":[{"created_at":"2014-02-21T15:52:24.000Z","description":"broke","id":"2354994440","location":"mea","name":"diane","profile_image_url":"https://pbs.twimg.com/profile_images/1526821401831026688/YVme9vgY_normal.jpg","protected":false,"url":"","username":"seokshuu","verified":false},{"created_at":"2021-01-25T23:31:33.000Z","description":"proofs winner #taefairy","entities":{"url":{"urls":[{"start":0,"end":23,"url":"https://t.co/vVo16A5mXM","expanded_url":"https://twitter.com/i/events/1483286885791375365","display_url":"twitter.com/i/events/14832…"}]},"description":{"hashtags":[{"start":14,"end":23,"tag":"taefairy"}]}},"id":"1353847968919547904","location":"check list active giveaways ↓","name":"taeby","profile_image_url":"https://pbs.twimg.com/profile_images/1433287575741943811/yGxUdigL_normal.png","protected":false,"url":"https://t.co/vVo16A5mXM","username":"taegiveaway","verified":false}],"tweets":[{"attachments":{},"author_id":"1353847968919547904","context_annotations":[{"domain":{"id":"65","name":"Interests and Hobbies Vertical","description":"Top level interests and hobbies groupings, like Food or Travel"},"entity":{"id":"1280550787207147521","name":"Arts & culture"}},{"domain":{"id":"66","name":"Interests and Hobbies Category","description":"A grouping of interests and hobbies entities, like Novelty Food or Destinations"},"entity":{"id":"913142676819648512","name":"Cryptocurrencies","description":"Cryptocurrency"}},{"domain":{"id":"66","name":"Interests and Hobbies Category","description":"A grouping of interests and hobbies entities, like Novelty Food or Destinations"},"entity":{"id":"1046577790353428480","name":"Visual arts","description":"Visual Arts"}},{"domain":{"id":"123","name":"Ongoing News Story","description":"Ongoing News Stories like 'Brexit'"},"entity":{"id":"1484601166080081920","name":"Russo-Ukrainian conflict"}},{"domain":{"id":"46","name":"Brand Category","description":"Categories within Brand Verticals that narrow down the scope of Brands"},"entity":{"id":"781974596752842752","name":"Services"}},{"domain":{"id":"47","name":"Brand","description":"Brands and Companies"},"entity":{"id":"10045225402","name":"Twitter"}}],"created_at":"2022-05-20T00:46:51.000Z","entities":{"annotations":[{"start":149,"end":155,"probability":0.8075,"type":"Place","normalized_text":"Ukraine"}],"hashtags":[{"start":174,"end":191,"tag":"StandWithUkraine"},{"start":192,"end":204,"tag":"HelpUkraine"},{"start":205,"end":210,"tag":"NFTs"},{"start":211,"end":215,"tag":"NFT"},{"start":216,"end":229,"tag":"NFTCommunity"},{"start":230,"end":237,"tag":"crypto"},{"start":238,"end":246,"tag":"Ukraine"},{"start":247,"end":251,"tag":"art"}],"mentions":[{"start":56,"end":69,"username":"ZelenskiyNFT","id":"1509950611483156488"},{"start":126,"end":139,"username":"ZelenskiyNFT","id":"1509950611483156488"}],"urls":[{"start":254,"end":277,"url":"https://t.co/mHrgcY1abQ","expanded_url":"https://twitter.com/zelenskiynft/status/1526282601991897088","display_url":"twitter.com/zelenskiynft/s…"}]},"geo":{},"id":"1527450748275290112","lang":"en","text":"$500 | 7.000.000 IDR • 7 DAYS 🌷\n\n$250\n- RT & Follow @ZelenskiyNFT\n\n(+) $250\n- QRT attached tweet + Tag 3 friends with👇\n\n\" @ZelenskiyNFT Stands For Ukraine 🇺🇦� WL Opened! #StandWithUkraine #HelpUkraine #NFTs #NFT #NFTCommunity #crypto #Ukraine #art \" https://t.co/mHrgcY1abQ"}]},"errors":[{"parameter":"entities.mentions.username","resource_id":"ZelenskiyNFT","value":"ZelenskiyNFT","detail":"User has been suspended: [ZelenskiyNFT].","title":"Forbidden","resource_type":"user","type":"https://api.twitter.com/2/problems/resource-not-found"}],"matching_rules":[{"id":"1527970068608561153","tag":"ukraine"}]}
at com.google.gson.Gson.fromJson(Gson.java:1006)
at com.google.gson.Gson.fromJson(Gson.java:956)
at com.google.gson.Gson.fromJson(Gson.java:905)
at com.google.gson.Gson.fromJson(Gson.java:876)
at com.twitter.clientlib.model.FilteredStreamingTweet.fromJson(FilteredStreamingTweet.java:283)
at fr.totetmatt.gephi.twitter.utils.listener.filtered.TweetsStreamListenersExecutor$TweetsQueuer.queueTweets(TweetsStreamListenersExecutor.java:124)
at fr.totetmatt.gephi.twitter.utils.listener.filtered.TweetsStreamListenersExecutor$TweetsQueuer.run(TweetsStreamListenersExecutor.java:109)
Caused by: java.io.IOException: Failed deserialization for FilteredStreamingTweet: 2 classes match result, expected 1. JSON: {"data":{"attachments":{"media_keys":["3_1529016941515378688","3_1529016942450774021"]},"author_id":"2354994440","created_at":"2022-05-24T08:30:23.000Z","entities":{"mentions":[{"start":0,"end":12,"username":"taegiveaway","id":"1353847968919547904"},{"start":13,"end":26,"username":"ZelenskiyNFT","id":"1509950611483156488"}],"urls":[{"start":41,"end":64,"url":"https://t.co/sT4XPjBilR","expanded_url":"https://twitter.com/seokshuu/status/1529016950554099713/photo/1","display_url":"pic.twitter.com/sT4XPjBilR","media_key":"3_1529016941515378688"},{"start":41,"end":64,"url":"https://t.co/sT4XPjBilR","expanded_url":"https://twitter.com/seokshuu/status/1529016950554099713/photo/1","display_url":"pic.twitter.com/sT4XPjBilR","media_key":"3_1529016942450774021"}]},"geo":{},"id":"1529016950554099713","in_reply_to_user_id":"1353847968919547904","lang":"en","referenced_tweets":[{"type":"replied_to","id":"1527450748275290112"}],"text":"@taegiveaway @ZelenskiyNFT acc suspended https://t.co/sT4XPjBilR"},"includes":{"media":[{"media_key":"3_1529016941515378688","type":"photo","url":"https://pbs.twimg.com/media/FTgozqaUEAAhmgJ.jpg"},{"media_key":"3_1529016942450774021","type":"photo","url":"https://pbs.twimg.com/media/FTgozt5VEAU9qVA.jpg"}],"users":[{"created_at":"2014-02-21T15:52:24.000Z","description":"broke","id":"2354994440","location":"mea","name":"diane","profile_image_url":"https://pbs.twimg.com/profile_images/1526821401831026688/YVme9vgY_normal.jpg","protected":false,"url":"","username":"seokshuu","verified":false},{"created_at":"2021-01-25T23:31:33.000Z","description":"proofs winner #taefairy","entities":{"url":{"urls":[{"start":0,"end":23,"url":"https://t.co/vVo16A5mXM","expanded_url":"https://twitter.com/i/events/1483286885791375365","display_url":"twitter.com/i/events/14832…"}]},"description":{"hashtags":[{"start":14,"end":23,"tag":"taefairy"}]}},"id":"1353847968919547904","location":"check list active giveaways ↓","name":"taeby","profile_image_url":"https://pbs.twimg.com/profile_images/1433287575741943811/yGxUdigL_normal.png","protected":false,"url":"https://t.co/vVo16A5mXM","username":"taegiveaway","verified":false}],"tweets":[{"attachments":{},"author_id":"1353847968919547904","context_annotations":[{"domain":{"id":"65","name":"Interests and Hobbies Vertical","description":"Top level interests and hobbies groupings, like Food or Travel"},"entity":{"id":"1280550787207147521","name":"Arts & culture"}},{"domain":{"id":"66","name":"Interests and Hobbies Category","description":"A grouping of interests and hobbies entities, like Novelty Food or Destinations"},"entity":{"id":"913142676819648512","name":"Cryptocurrencies","description":"Cryptocurrency"}},{"domain":{"id":"66","name":"Interests and Hobbies Category","description":"A grouping of interests and hobbies entities, like Novelty Food or Destinations"},"entity":{"id":"1046577790353428480","name":"Visual arts","description":"Visual Arts"}},{"domain":{"id":"123","name":"Ongoing News Story","description":"Ongoing News Stories like 'Brexit'"},"entity":{"id":"1484601166080081920","name":"Russo-Ukrainian conflict"}},{"domain":{"id":"46","name":"Brand Category","description":"Categories within Brand Verticals that narrow down the scope of Brands"},"entity":{"id":"781974596752842752","name":"Services"}},{"domain":{"id":"47","name":"Brand","description":"Brands and Companies"},"entity":{"id":"10045225402","name":"Twitter"}}],"created_at":"2022-05-20T00:46:51.000Z","entities":{"annotations":[{"start":149,"end":155,"probability":0.8075,"type":"Place","normalized_text":"Ukraine"}],"hashtags":[{"start":174,"end":191,"tag":"StandWithUkraine"},{"start":192,"end":204,"tag":"HelpUkraine"},{"start":205,"end":210,"tag":"NFTs"},{"start":211,"end":215,"tag":"NFT"},{"start":216,"end":229,"tag":"NFTCommunity"},{"start":230,"end":237,"tag":"crypto"},{"start":238,"end":246,"tag":"Ukraine"},{"start":247,"end":251,"tag":"art"}],"mentions":[{"start":56,"end":69,"username":"ZelenskiyNFT","id":"1509950611483156488"},{"start":126,"end":139,"username":"ZelenskiyNFT","id":"1509950611483156488"}],"urls":[{"start":254,"end":277,"url":"https://t.co/mHrgcY1abQ","expanded_url":"https://twitter.com/zelenskiynft/status/1526282601991897088","display_url":"twitter.com/zelenskiynft/s…"}]},"geo":{},"id":"1527450748275290112","lang":"en","text":"$500 | 7.000.000 IDR • 7 DAYS 🌷\n\n$250\n- RT & Follow @ZelenskiyNFT\n\n(+) $250\n- QRT attached tweet + Tag 3 friends with👇\n\n\" @ZelenskiyNFT Stands For Ukraine 🇺🇦� WL Opened! #StandWithUkraine #HelpUkraine #NFTs #NFT #NFTCommunity #crypto #Ukraine #art \" https://t.co/mHrgcY1abQ"}]},"errors":[{"parameter":"entities.mentions.username","resource_id":"ZelenskiyNFT","value":"ZelenskiyNFT","detail":"User has been suspended: [ZelenskiyNFT].","title":"Forbidden","resource_type":"user","type":"https://api.twitter.com/2/problems/resource-not-found"}],"matching_rules":[{"id":"1527970068608561153","tag":"ukraine"}]}
at com.twitter.clientlib.model.FilteredStreamingTweet$CustomTypeAdapterFactory$1.read(FilteredStreamingTweet.java:155)
at com.twitter.clientlib.model.FilteredStreamingTweet$CustomTypeAdapterFactory$1.read(FilteredStreamingTweet.java:92)
at com.google.gson.TypeAdapter$1.read(TypeAdapter.java:199)
at com.google.gson.Gson.fromJson(Gson.java:991)
... 6 more
Trying to use Twitter Stream Stream. When parsing stream buffer response with
FilteredStreamingTweet.fromJson
got this error :Expected behavior
When using FilteredStreamingTweet.fromJson, expecing to have most of the response parsed
Actual behavior
Failing
Steps to reproduce the behavior
Get HelloWorldStreaming example, Replace sample stream to have a valid search stream Replace
StreamingTweet
toFilteredStreamingTweet
Run the example.Extra data
Full log dump
Project context : https://github.com/totetmatt/gephi-plugins/blob/twitter_v2/modules/TwitterV2/src/main/java/fr/totetmatt/gephi/twitter/utils/listener/filtered/TweetsStreamListenersExecutor.java#L124