Giter Site home page Giter Site logo

Comments (9)

zacmos avatar zacmos commented on August 25, 2024 1

@nrv, the API has been updated to handle empty urls.

from twitter-api-java-sdk.

nrv avatar nrv commented on August 25, 2024

Seems to happen on a witheld account where profile_image_url is empty

{"protected":false,"name":"","created_at":"2011-01-14T09:27:09.000Z","username":"sputnik_fr","entities":{"description":{"urls":[{"start":340,"end":350,"url":"https://support.twitter.com/articles/20169222","expanded_url":"https://support.twitter.com/articles/20169222","display_url":"Learn more"}]}},"public_metrics":{"followers_count":95621,"following_count":219,"tweet_count":236481,"listed_count":1358},"profile_image_url":"","pinned_tweet_id":"1498740347144482820","description":"@sputnik_fr's account has been withheld in Portugal, Finland, Sweden, Ireland, Slovenia, Czech Republic, Poland, Slovakia, Hungary, Italy, Malta, Germany, Greece, Romania, Netherlands, Bulgaria, Austria, Luxembourg, Latvia, United Kingdom, Denmark, Lithuania, Croatia, Estonia, Cyprus, France, Spain, Belgium in response to a legal demand. Learn more.","url":"","id":"238080747","verified":true,"withheld":{"country_codes":["AT","BE","BG","CY","CZ","DE","DK","EE","ES","FI","FR","GB","GR","HR","HU","IE","IT","LT","LU","LV","MT","NL","PL","PT","RO","SE","SI","SK"],"scope":"user"}}

from twitter-api-java-sdk.

zacmos avatar zacmos commented on August 25, 2024

@nrv, thank you for opening this issue, the fix will be done at the API level and not inside the SDK.
We'll let you know once it's done.

from twitter-api-java-sdk.

rzo1 avatar rzo1 commented on August 25, 2024

I am encountering the same issue for the streaming endpoint.

java.net.MalformedURLException: no protocol: 
com.google.gson.JsonIOException: java.net.MalformedURLException: no protocol: 
	at com.google.gson.TypeAdapter.fromJsonTree(TypeAdapter.java:287)
	at com.twitter.clientlib.model.User$CustomTypeAdapterFactory$1.read(User.java:623)
	at com.twitter.clientlib.model.User$CustomTypeAdapterFactory$1.read(User.java:612)
	at com.google.gson.TypeAdapter$1.read(TypeAdapter.java:199)
	at com.google.gson.internal.bind.TypeAdapterRuntimeTypeWrapper.read(TypeAdapterRuntimeTypeWrapper.java:41)
	at com.google.gson.internal.bind.CollectionTypeAdapterFactory$Adapter.read(CollectionTypeAdapterFactory.java:82)
	at com.google.gson.internal.bind.CollectionTypeAdapterFactory$Adapter.read(CollectionTypeAdapterFactory.java:61)
	at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.read(ReflectiveTypeAdapterFactory.java:130)
	at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:221)
	at com.google.gson.TypeAdapter.fromJsonTree(TypeAdapter.java:285)
	at com.twitter.clientlib.model.Expansions$CustomTypeAdapterFactory$1.read(Expansions.java:459)
	at com.twitter.clientlib.model.Expansions$CustomTypeAdapterFactory$1.read(Expansions.java:448)
	at com.google.gson.TypeAdapter$1.read(TypeAdapter.java:199)
	at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.read(ReflectiveTypeAdapterFactory.java:130)
	at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:221)
	at com.google.gson.TypeAdapter.fromJsonTree(TypeAdapter.java:285)
	at com.twitter.clientlib.model.StreamingTweetResponse$CustomTypeAdapterFactory$1.read(StreamingTweetResponse.java:274)
	at com.twitter.clientlib.model.StreamingTweetResponse$CustomTypeAdapterFactory$1.read(StreamingTweetResponse.java:263)
	at com.google.gson.TypeAdapter$1.read(TypeAdapter.java:199)
	at com.google.gson.Gson.fromJson(Gson.java:991)
	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.StreamingTweetResponse.fromJson(StreamingTweetResponse.java:289)
	at  com.example.TweetsStreamListenersExecutor$TweetsQueuer.queueTweets(TweetsStreamListenersExecutor.java:198)
	at com.example.TweetsStreamListenersExecutor$TweetsQueuer.run(TweetsStreamListenersExecutor.java:179)
	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
	at java.base/java.lang.Thread.run(Thread.java:833)
Caused by: java.net.MalformedURLException: no protocol: 
	at java.base/java.net.URL.<init>(URL.java:674)
	at java.base/java.net.URL.<init>(URL.java:569)
	at java.base/java.net.URL.<init>(URL.java:516)
	at com.google.gson.internal.bind.TypeAdapters$21.read(TypeAdapters.java:502)
	at com.google.gson.internal.bind.TypeAdapters$21.read(TypeAdapters.java:494)
	at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.read(ReflectiveTypeAdapterFactory.java:130)
	at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:221)
	at com.google.gson.TypeAdapter.fromJsonTree(TypeAdapter.java:285)
	... 30 more

from twitter-api-java-sdk.

noguespi avatar noguespi commented on August 25, 2024

not fixed in latest version v2.0.3

com.google.gson.JsonIOException: java.net.MalformedURLException: no protocol: 
	at com.google.gson.TypeAdapter.fromJsonTree(TypeAdapter.java:287)
	at com.twitter.clientlib.model.User$CustomTypeAdapterFactory$1.read(User.java:623)
	at com.twitter.clientlib.model.User$CustomTypeAdapterFactory$1.read(User.java:612)
	at com.google.gson.TypeAdapter$1.read(TypeAdapter.java:199)
	at com.google.gson.internal.bind.TypeAdapterRuntimeTypeWrapper.read(TypeAdapterRuntimeTypeWrapper.java:41)
	at com.google.gson.internal.bind.CollectionTypeAdapterFactory$Adapter.read(CollectionTypeAdapterFactory.java:82)
	at com.google.gson.internal.bind.CollectionTypeAdapterFactory$Adapter.read(CollectionTypeAdapterFactory.java:61)
	at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.read(ReflectiveTypeAdapterFactory.java:130)
	at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:221)
	at com.google.gson.TypeAdapter.fromJsonTree(TypeAdapter.java:285)
	at com.twitter.clientlib.model.Get2UsersIdFollowersResponse$CustomTypeAdapterFactory$1.read(Get2UsersIdFollowersResponse.java:325)
	at com.twitter.clientlib.model.Get2UsersIdFollowersResponse$CustomTypeAdapterFactory$1.read(Get2UsersIdFollowersResponse.java:314)
	at com.google.gson.TypeAdapter$1.read(TypeAdapter.java:199)
	at com.google.gson.Gson.fromJson(Gson.java:991)
	at com.google.gson.Gson.fromJson(Gson.java:956)
	at com.google.gson.Gson.fromJson(Gson.java:905)
	at com.twitter.clientlib.JSON.deserialize(JSON.java:978)
	at com.twitter.clientlib.ApiClient.deserialize(ApiClient.java:959)
	at com.twitter.clientlib.ApiClient.handleResponse(ApiClient.java:1190)
	at com.twitter.clientlib.ApiClient.execute(ApiClient.java:1091)
	at com.twitter.clientlib.api.UsersApi.usersIdFollowersWithHttpInfo(UsersApi.java:2965)
	at com.twitter.clientlib.api.UsersApi.access$4900(UsersApi.java:77)
	at com.twitter.clientlib.api.UsersApi$APIusersIdFollowersRequest.execute(UsersApi.java:3084)

from twitter-api-java-sdk.

ziorufus avatar ziorufus commented on August 25, 2024

It does not work even when the URL is contained into the field but the protocol is missing.

com.google.gson.JsonIOException: java.net.MalformedURLException: no protocol: Loulasassy.com
        at com.google.gson.TypeAdapter.fromJsonTree(TypeAdapter.java:287)
        at com.twitter.clientlib.model.UrlEntity$CustomTypeAdapterFactory$1.read(UrlEntity.java:543)
        at com.twitter.clientlib.model.UrlEntity$CustomTypeAdapterFactory$1.read(UrlEntity.java:532)
        at com.google.gson.TypeAdapter$1.read(TypeAdapter.java:199)
        at com.google.gson.internal.bind.TypeAdapterRuntimeTypeWrapper.read(TypeAdapterRuntimeTypeWrapper.java:41)
        at com.google.gson.internal.bind.CollectionTypeAdapterFactory$Adapter.read(CollectionTypeAdapterFactory.java:82)
        at com.google.gson.internal.bind.CollectionTypeAdapterFactory$Adapter.read(CollectionTypeAdapterFactory.java:61)
...

I even do not know which parameter I should remove, since I've already deleted profile_image_url. Any idea? Is it possible to fix this in the next version? Or, as an alternative, is it possible to consider the URLs as strings, so that this problem won't happen anymore?

from twitter-api-java-sdk.

nrv avatar nrv commented on August 25, 2024

from twitter-api-java-sdk.

ziorufus avatar ziorufus commented on August 25, 2024

The problem is that this does not happen only with profile_image_url. In my case, it also happen in old tweets for entities in user fields. I guess that old tweets are not correctly formatted so that the protocol is always provided by the API.

from twitter-api-java-sdk.

paul-b-johnson avatar paul-b-johnson commented on August 25, 2024

I see java.net.MalformedURLException: no protocol: occasionally when using the findUsersById or findUsersByUsername and including the profile_image_url field. I see this issue has been open for a while.

In User, can profileImageUrl be a String rather than a URL? Or can exceptions could be handled so the entire call doesn't fail?

from twitter-api-java-sdk.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.