xdevplatform / twitter-api-java-sdk

A Java SDK for the Twitter API
https://developer.twitter.com/en/docs/twitter-api
Apache License 2.0
237 stars 83 forks source link

Unexpected FileNotFoundException while upgrading from 2.0.2 to 2.0.3 #45

Open rzo1 opened 2 years ago

rzo1 commented 2 years ago

If no sdk.properties is present, the following stacktrace is printed:

java.io.FileNotFoundException: sdk.properties (No such file or directory)
        at java.base/java.io.FileInputStream.open0(Native Method)
        at java.base/java.io.FileInputStream.open(FileInputStream.java:216)
        at java.base/java.io.FileInputStream.<init>(FileInputStream.java:157)
        at java.base/java.io.FileInputStream.<init>(FileInputStream.java:111)
        at com.twitter.clientlib.SDKConfig.<clinit>(SDKConfig.java:38)
        at com.twitter.clientlib.api.TwitterApi.init(TwitterApi.java:75)
        at com.twitter.clientlib.api.TwitterApi.<init>(TwitterApi.java:50)

The change was introduced with #32.

Can we simply ignore the exception in https://github.com/twitterdev/twitter-api-java-sdk/blob/main/src/main/java/com/twitter/clientlib/SDKConfig.java#L40 instead of printing the stacktrace, which might confuse users?

AFAIK the sdk.properties aren't mandatory, so perhaps it would be best to just ignore the exception instead of printing the stacktrace?

In addition, I am wondering, if this snippet shouldn't use the classloader in order to load the properties file?

nn81 commented 1 year ago

Same thing here. That error has no reason to exist and should ignore whenever not finding an sdk.properties file.

As quick fix, I've just created an empty file at the root of the project and no more unnecessary error messages on startup.

janikdotzel commented 1 year ago

Experiencing the same here. It is indeed confusing. Thanks @nn81 for the suggestion. Will do the same to keep my log clean.

0xacx commented 1 year ago

I get the same error in 2.0.3 version. This, combined with the fact that twitter api was not working properly yesterday, led me to wonder what went wrong and if additional configuration was needed. Good to know the sdk.properties file is not necessary.

drveresh commented 1 year ago

I am also facing the same issue.

kosuodhmwa commented 8 months ago

self-cite: <i've just created an empty file sdk.properties in project's root folder then that message was gone>

https://github.com/twitterdev/twitter-api-java-sdk/issues/75

adequate solution?

thx for feedback.