| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
…y() to avoid a race condition in HttpUrlConnector#secureConnection
|
@pavelbucek are you the correct person to review this? |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
@mpotociar @petrbouda this PR is a potential fix for #3293
From my understanding of the current code, the logic for using a custom SSL socket factory is:
Currently, the first check is done via:
The issue with this code is that HttpsURLConnection.getDefaultSSLSocketFactory() is not thread safe. The implementation looks like:
If there are concurrent requests, one of them may end up creating a separate SSLSocketFactory that is not the default. The comparison check above fails and the request ends up using the default SSL context instead of the provided one.
The fix in this PR is to call HttpsURLConnection.getDefaultSSLSocketFactory() in a static initializer block for the class so that the default SSLContext is present when the comparison is made in HttpUrlConnector#secureConnector
I'm open to feedback on alternate approaches to resolving this.