Skip to content

Commit

Permalink
Merge pull request square#2741 from square/jwilson.0722.dusting
Browse files Browse the repository at this point in the history
Remove some dead code pointed out by running coverage.
  • Loading branch information
swankjesse authored Jul 24, 2016
2 parents ced243e + 591d595 commit 6014ab9
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 151 deletions.
8 changes: 8 additions & 0 deletions okhttp-tests/src/test/java/okhttp3/HeadersTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -329,4 +329,12 @@ public final class HeadersTest {
assertFalse(headers1.equals(headers2));
assertFalse(headers1.hashCode() == headers2.hashCode());
}

@Test public void headersToString() {
Headers headers = new Headers.Builder()
.add("A", "a")
.add("B", "bb")
.build();
assertEquals("A: a\nB: bb\n", headers.toString());
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import java.net.SocketPermission;
import java.net.URL;
import java.security.Permission;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Date;
Expand Down Expand Up @@ -302,8 +301,7 @@ private static String responseSourceHeader(Response response) {
.build();
}

@Override
public void setInstanceFollowRedirects(boolean followRedirects) {
@Override public void setInstanceFollowRedirects(boolean followRedirects) {
client = client.newBuilder()
.followRedirects(followRedirects)
.build();
Expand Down Expand Up @@ -492,12 +490,7 @@ private Response getResponse() throws IOException {
return;
}

// TODO: Deprecate use of X-Android-Transports header?
if ("X-Android-Transports".equals(field) || "X-Android-Protocols".equals(field)) {
setProtocols(newValue, false /* append */);
} else {
requestHeaders.set(field, newValue);
}
requestHeaders.set(field, newValue);
}

@Override public void setIfModifiedSince(long newValue) {
Expand Down Expand Up @@ -526,35 +519,7 @@ private Response getResponse() throws IOException {
return;
}

// TODO: Deprecate use of X-Android-Transports header?
if ("X-Android-Transports".equals(field) || "X-Android-Protocols".equals(field)) {
setProtocols(value, true /* append */);
} else {
requestHeaders.add(field, value);
}
}

/*
* Splits and validates a comma-separated string of protocols.
* When append == false, we require that the transport list contains "http/1.1".
* Throws {@link IllegalStateException} when one of the protocols isn't
* defined in {@link Protocol OkHttp's protocol enumeration}.
*/
private void setProtocols(String protocolsString, boolean append) {
List<Protocol> protocolsList = new ArrayList<>();
if (append) {
protocolsList.addAll(client.protocols());
}
for (String protocol : protocolsString.split(",", -1)) {
try {
protocolsList.add(Protocol.get(protocol));
} catch (IOException e) {
throw new IllegalStateException(e);
}
}
client = client.newBuilder()
.protocols(protocolsList)
.build();
requestHeaders.add(field, value);
}

@Override public void setRequestMethod(String method) throws ProtocolException {
Expand Down
13 changes: 6 additions & 7 deletions okhttp/src/main/java/okhttp3/Response.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,15 +71,14 @@ private Response(Builder builder) {
}

/**
* The wire-level request that initiated this HTTP response. This is not
* necessarily the same request issued by the application:
* The wire-level request that initiated this HTTP response. This is not necessarily the same
* request issued by the application:
*
* <ul>
* <li>It may be transformed by the HTTP client. For example, the client
* may copy headers like {@code Content-Length} from the request body.
* <li>It may be the request generated in response to an HTTP redirect or
* authentication challenge. In this case the request URL may be
* different than the initial request URL.
* <li>It may be transformed by the HTTP client. For example, the client may copy headers like
* {@code Content-Length} from the request body.
* <li>It may be the request generated in response to an HTTP redirect or authentication
* challenge. In this case the request URL may be different than the initial request URL.
* </ul>
*/
public Request request() {
Expand Down
23 changes: 0 additions & 23 deletions okhttp/src/main/java/okhttp3/internal/Util.java
Original file line number Diff line number Diff line change
Expand Up @@ -125,29 +125,6 @@ public static void closeQuietly(ServerSocket serverSocket) {
}
}

/**
* Closes {@code a} and {@code b}. If either close fails, this completes the other close and
* rethrows the first encountered exception.
*/
public static void closeAll(Closeable a, Closeable b) throws IOException {
Throwable thrown = null;
try {
a.close();
} catch (Throwable e) {
thrown = e;
}
try {
b.close();
} catch (Throwable e) {
if (thrown == null) thrown = e;
}
if (thrown == null) return;
if (thrown instanceof IOException) throw (IOException) thrown;
if (thrown instanceof RuntimeException) throw (RuntimeException) thrown;
if (thrown instanceof Error) throw (Error) thrown;
throw new AssertionError(thrown);
}

/**
* Attempts to exhaust {@code source}, returning true if successful. This is useful when reading a
* complete source is helpful, such as when doing so completes a cache body or frees a socket
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,6 @@ public boolean isCanceled() {
return canceled;
}

public OkHttpClient client() {
return client;
}

public void setForWebSocket(boolean forWebSocket) {
this.forWebSocket = forWebSocket;
}
Expand Down
12 changes: 0 additions & 12 deletions okhttp/src/main/java/okhttp3/internal/http2/Settings.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,10 @@ public final class Settings {
static final int MAX_HEADER_LIST_SIZE = 6;
/** Window size in bytes. */
static final int INITIAL_WINDOW_SIZE = 7;
/** Flow control options. */
static final int FLOW_CONTROL_OPTIONS = 10;

/** Total number of settings. */
static final int COUNT = 10;

/** If set, flow control is disabled for streams directed to the sender of these settings. */
static final int FLOW_CONTROL_OPTIONS_DISABLED = 0x1;

/** Bitfield of which flags that values. */
private int set;

Expand Down Expand Up @@ -120,13 +115,6 @@ int getInitialWindowSize() {
return (bit & set) != 0 ? values[INITIAL_WINDOW_SIZE] : DEFAULT_INITIAL_WINDOW_SIZE;
}

// TODO: honor this setting.
boolean isFlowControlDisabled() {
int bit = 1 << FLOW_CONTROL_OPTIONS;
int value = (bit & set) != 0 ? values[FLOW_CONTROL_OPTIONS] : 0;
return (value & FLOW_CONTROL_OPTIONS_DISABLED) != 0;
}

/**
* Writes {@code other} into this. If any setting is populated by this and {@code other}, the
* value and flags from {@code other} will be kept.
Expand Down
9 changes: 9 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,15 @@
<alpn.jdk8.version>8.1.8.v20160420</alpn.jdk8.version>
</properties>
</profile>
<profile>
<id>alpn-when-jdk8_101</id>
<activation>
<jdk>1.8.0_101</jdk>
</activation>
<properties>
<alpn.jdk8.version>8.1.8.v20160420</alpn.jdk8.version>
</properties>
</profile>
</profiles>
</project>

0 comments on commit 6014ab9

Please sign in to comment.