twitter-api-java-sdk icon indicating copy to clipboard operation
twitter-api-java-sdk copied to clipboard

Unexpected FileNotFoundException while upgrading from 2.0.2 to 2.0.3

Open rzo1 opened this issue 2 years ago • 5 comments

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?

rzo1 avatar Oct 03 '22 18:10 rzo1

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.

nn81 avatar Oct 15 '22 10:10 nn81

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

janikdotzel avatar Feb 16 '23 08:02 janikdotzel

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.

0xacx avatar Mar 03 '23 14:03 0xacx

I am also facing the same issue.

drveresh avatar Jul 09 '23 17:07 drveresh

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.

kosuodhmwa avatar Jan 30 '24 10:01 kosuodhmwa