Skip to content

Commit

Permalink
Set no-follow-redirects local instead of global
Browse files Browse the repository at this point in the history
When setting no-follow-redirects for RequestBuilder#getRedirectUrl()
(e.g., avatar requests), do so only for this one request. Previously, it
was set globally for all requests, then set back to its initial state
after the request completed. This should prevent multithreading issues
where numerous threads are attempting to alter the global state of
HttpURLConnection#setFollowRedirects().

Fixes #94
  • Loading branch information
ceyko committed May 3, 2016
1 parent 9836a76 commit cb5ca7b
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions src/main/java/com/tumblr/jumblr/request/RequestBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,8 @@ public RequestBuilder(JumblrClient client) {
public String getRedirectUrl(String path) {
OAuthRequest request = this.constructGet(path, null);
sign(request);
boolean presetVal = HttpURLConnection.getFollowRedirects();
HttpURLConnection.setFollowRedirects(false);
request.setFollowRedirects(false);
Response response = request.send();
HttpURLConnection.setFollowRedirects(presetVal);
if (response.getCode() == 301) {
return response.getHeader("Location");
} else {
Expand Down

0 comments on commit cb5ca7b

Please sign in to comment.