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

NullPointerException caused by outdated OkHttp #298

Open
omarathon opened this issue Jan 1, 2020 · 1 comment
Open

NullPointerException caused by outdated OkHttp #298

omarathon opened this issue Jan 1, 2020 · 1 comment

Comments

@omarathon
Copy link

omarathon commented Jan 1, 2020

When one creates an OkHttpNetworkAdaptor without specifying their own working OkHttpClient, the default OkHttpClient generated may have a null ProxySelector.

This causes a NullPointerException in my program using JRAW.

I discovered that ProxySelector.getDefault() returns null for Linux machines, so to circumvient the error I created an OkHttpNetworkAdaptor with a custom OkHttpClient, which has a custom ProxySelector which simply doesn't use a proxy (see https://github.com/square/okhttp/pull/4237/files, the NullProxySelector which was added).

OkHttp has been updated to implement such a NullProxySelector. Please update OkHttp, or implement the above change in https://github.com/mattbdean/JRAW/blob/master/lib/src/main/kotlin/net/dean/jraw/http/OkHttpNetworkAdapter.kt, specifically the line private val http: OkHttpClient = OkHttpClient() - you must use the OkHttpClient.Builder class and provide the ProxySelector. Such ProxySelector should either be ProxySelector.getDefault(), however if null, the proposed NullProxySelector.

I'd make a PR but this can simply be resolved by updating OkHttp.

Cheers,
omarathon

@omarathon
Copy link
Author

Note: this issue was officially raised on the OkHttp GitHub page:
square/okhttp#4232

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

No branches or pull requests

1 participant