Skip to content

Commit

Permalink
Merge pull request #3285 from square/jwilson.0415.hide_eventlistener
Browse files Browse the repository at this point in the history
Hide EventListener from the public API for OkHttp 3.7.
  • Loading branch information
swankjesse committed Apr 16, 2017
2 parents 31f04d7 + 60b1c1d commit a94f952
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
3 changes: 2 additions & 1 deletion okhttp/src/main/java/okhttp3/EventListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
import java.net.InetAddress;
import java.util.List;

public abstract class EventListener {
// TODO(jwilson): make this public after the 3.7 release.
abstract class EventListener {
public static final EventListener NONE = new EventListener() {
};

Expand Down
9 changes: 6 additions & 3 deletions okhttp/src/main/java/okhttp3/OkHttpClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,8 @@ public List<Interceptor> networkInterceptors() {
return networkInterceptors;
}

public EventListener.Factory eventListenerFactory() {
// TODO(jwilson): make this public after the 3.7 release.
/*public*/ EventListener.Factory eventListenerFactory() {
return eventListenerFactory;
}

Expand Down Expand Up @@ -887,13 +888,15 @@ public Builder addNetworkInterceptor(Interceptor interceptor) {
return this;
}

public Builder eventListener(EventListener eventListener) {
// TODO(jwilson): make this public after the 3.7 release.
/*public*/ Builder eventListener(EventListener eventListener) {
if (eventListener == null) throw new NullPointerException("eventListener == null");
this.eventListenerFactory = EventListener.factory(eventListener);
return this;
}

public Builder eventListenerFactory(EventListener.Factory eventListenerFactory) {
// TODO(jwilson): make this public after the 3.7 release.
/*public*/ Builder eventListenerFactory(EventListener.Factory eventListenerFactory) {
if (eventListenerFactory == null) {
throw new NullPointerException("eventListenerFactory == null");
}
Expand Down
2 changes: 2 additions & 0 deletions okhttp/src/main/java/okhttp3/RealCall.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ final class RealCall implements Call {
this.originalRequest = originalRequest;
this.forWebSocket = forWebSocket;
this.retryAndFollowUpInterceptor = new RetryAndFollowUpInterceptor(client, forWebSocket);

// TODO(jwilson): this is unsafe publication and not threadsafe.
this.eventListener = eventListenerFactory.create(this);
}

Expand Down

0 comments on commit a94f952

Please sign in to comment.