Skip to content

Commit

Permalink
Update to OkHttp 2.0.0, which has a new OkUrlFactory
Browse files Browse the repository at this point in the history
OkHttp changed API with v2.0.0, and the `client.open(url)` method no
longer exists:

"URLConnection support has moved to the okhttp-urlconnection module.
If you're upgrading from 1.x, this change will impact you. You will
need to add the okhttp-urlconnection module to your project and use
the OkUrlFactory to create new instances of HttpURLConnection"

https://github.com/square/okhttp/blob/master/CHANGELOG.md#version-200-rc1
  • Loading branch information
rtyley committed Jun 28, 2014
1 parent 7e35716 commit 0a37ac9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@
</dependency>
<dependency>
<groupId>com.squareup.okhttp</groupId>
<artifactId>okhttp</artifactId>
<version>1.5.3</version>
<artifactId>okhttp-urlconnection</artifactId>
<version>2.0.0</version>
<optional>true</optional>
</dependency>
<dependency>
Expand Down
9 changes: 5 additions & 4 deletions src/main/java/org/kohsuke/github/extras/OkHttpConnector.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.kohsuke.github.extras;

import com.squareup.okhttp.OkHttpClient;
import com.squareup.okhttp.OkUrlFactory;
import org.kohsuke.github.HttpConnector;

import java.io.IOException;
Expand All @@ -19,13 +20,13 @@
* @author Kohsuke Kawaguchi
*/
public class OkHttpConnector implements HttpConnector {
private final OkHttpClient client;
private final OkUrlFactory urlFactory;

public OkHttpConnector(OkHttpClient client) {
this.client = client;
public OkHttpConnector(OkUrlFactory urlFactory) {
this.urlFactory = urlFactory;
}

public HttpURLConnection connect(URL url) throws IOException {
return client.open(url);
return urlFactory.open(url);
}
}

0 comments on commit 0a37ac9

Please sign in to comment.