Skip to content

Commit

Permalink
Sort imports and wrap documentation at 100 columns.
Browse files Browse the repository at this point in the history
This is a mechanical refactoring. The only thing I had trouble with is IntelliJ's
weak support for <ul> tags in Javadoc.
  • Loading branch information
squarejesse committed Dec 24, 2015
1 parent 86694b9 commit 98ae0fb
Show file tree
Hide file tree
Showing 182 changed files with 2,057 additions and 2,142 deletions.
6 changes: 4 additions & 2 deletions benchmarks/pom.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
Expand Down Expand Up @@ -88,7 +90,7 @@
<argument>-Xmx512m</argument>
<commandlineArgs>-Xbootclasspath/p:${bootclasspath}</commandlineArgs>
<argument>-classpath</argument>
<classpath />
<classpath/>
<argument>okhttp3.benchmarks.Benchmark</argument>
</arguments>
</configuration>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@
*/
package okhttp3.benchmarks;

import okhttp3.HttpUrl;
import okhttp3.internal.SslContextBuilder;
import java.io.IOException;
import java.io.InputStream;
import java.util.concurrent.TimeUnit;
import java.util.zip.GZIPInputStream;
import javax.net.ssl.SSLContext;
import okhttp3.HttpUrl;
import okhttp3.internal.SslContextBuilder;
import org.apache.http.Header;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
Expand Down
30 changes: 15 additions & 15 deletions benchmarks/src/main/java/okhttp3/benchmarks/Benchmark.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,6 @@
import com.google.caliper.Param;
import com.google.caliper.model.ArbitraryMeasurement;
import com.google.caliper.runner.CaliperMain;
import okhttp3.HttpUrl;
import okhttp3.Protocol;
import okhttp3.internal.SslContextBuilder;
import okhttp3.mockwebserver.Dispatcher;
import okhttp3.mockwebserver.MockResponse;
import okhttp3.mockwebserver.MockWebServer;
import okhttp3.mockwebserver.RecordedRequest;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
Expand All @@ -34,30 +27,37 @@
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.net.ssl.SSLContext;
import okhttp3.HttpUrl;
import okhttp3.Protocol;
import okhttp3.internal.SslContextBuilder;
import okhttp3.mockwebserver.Dispatcher;
import okhttp3.mockwebserver.MockResponse;
import okhttp3.mockwebserver.MockWebServer;
import okhttp3.mockwebserver.RecordedRequest;
import okio.Buffer;
import okio.GzipSink;

/**
* This benchmark is fake, but may be useful for certain relative comparisons.
* It uses a local connection to a MockWebServer to measure how many identical
* requests per second can be carried over a fixed number of threads.
* This benchmark is fake, but may be useful for certain relative comparisons. It uses a local
* connection to a MockWebServer to measure how many identical requests per second can be carried
* over a fixed number of threads.
*/
public class Benchmark extends com.google.caliper.Benchmark {
private static final int NUM_REPORTS = 10;
private static final boolean VERBOSE = false;

private final Random random = new Random(0);

/** Which client to run.*/
/** Which client to run. */
@Param
Client client;

/** How many concurrent requests to execute. */
@Param({ "1", "10" })
@Param({"1", "10"})
int concurrencyLevel;

/** How many requests to enqueue to await threads to execute them. */
@Param({ "10" })
@Param({"10"})
int targetBacklog;

/** True to use TLS. */
Expand All @@ -74,11 +74,11 @@ public class Benchmark extends com.google.caliper.Benchmark {
boolean chunked;

/** The size of the HTTP response body, in uncompressed bytes. */
@Param({ "128", "1048576" })
@Param({"128", "1048576"})
int bodyByteCount;

/** How many additional headers were included, beyond the built-in ones. */
@Param({ "0", "20" })
@Param({"0", "20"})
int headerCount;

/** Which ALPN protocols are in use. Only useful with TLS. */
Expand Down
2 changes: 2 additions & 0 deletions benchmarks/src/main/java/okhttp3/benchmarks/HttpClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
/** An HTTP client to benchmark. */
interface HttpClient {
void prepare(Benchmark benchmark);

void enqueue(HttpUrl url) throws Exception;

boolean acceptingJobs();
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
*/
package okhttp3.benchmarks;

import okhttp3.HttpUrl;
import okhttp3.internal.SslContextBuilder;
import io.netty.bootstrap.Bootstrap;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.PooledByteBufAllocator;
Expand Down Expand Up @@ -46,6 +44,8 @@
import java.util.concurrent.TimeUnit;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLEngine;
import okhttp3.HttpUrl;
import okhttp3.internal.SslContextBuilder;

/** Netty isn't an HTTP client, but it's almost one. */
class NettyHttpClient implements HttpClient {
Expand Down
12 changes: 6 additions & 6 deletions benchmarks/src/main/java/okhttp3/benchmarks/OkHttp.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,18 @@
*/
package okhttp3.benchmarks;

import okhttp3.Call;
import okhttp3.HttpUrl;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.ResponseBody;
import okhttp3.internal.SslContextBuilder;
import java.io.IOException;
import java.util.concurrent.TimeUnit;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLSession;
import javax.net.ssl.SSLSocketFactory;
import okhttp3.Call;
import okhttp3.HttpUrl;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.ResponseBody;
import okhttp3.internal.SslContextBuilder;

class OkHttp extends SynchronousHttpClient {
private static final boolean VERBOSE = false;
Expand Down
16 changes: 8 additions & 8 deletions benchmarks/src/main/java/okhttp3/benchmarks/OkHttpAsync.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,6 @@
*/
package okhttp3.benchmarks;

import okhttp3.Callback;
import okhttp3.Dispatcher;
import okhttp3.HttpUrl;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import okhttp3.ResponseBody;
import okhttp3.internal.SslContextBuilder;
import java.io.IOException;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
Expand All @@ -32,6 +24,14 @@
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLSession;
import javax.net.ssl.SSLSocketFactory;
import okhttp3.Callback;
import okhttp3.Dispatcher;
import okhttp3.HttpUrl;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import okhttp3.ResponseBody;
import okhttp3.internal.SslContextBuilder;

class OkHttpAsync implements HttpClient {
private static final boolean VERBOSE = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
*/
package okhttp3.benchmarks;

import okhttp3.HttpUrl;
import java.io.IOException;
import java.io.InputStream;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import okhttp3.HttpUrl;

/** Any HTTP client with a blocking API. */
abstract class SynchronousHttpClient implements HttpClient {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
*/
package okhttp3.benchmarks;

import okhttp3.HttpUrl;
import okhttp3.internal.SslContextBuilder;
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
Expand All @@ -27,6 +25,8 @@
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLSession;
import javax.net.ssl.SSLSocketFactory;
import okhttp3.HttpUrl;
import okhttp3.internal.SslContextBuilder;

class UrlConnection extends SynchronousHttpClient {
private static final boolean VERBOSE = false;
Expand Down
10 changes: 9 additions & 1 deletion checkstyle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,15 @@
<module name="ParenPad"/>
<module name="TypecastParenPad"/>
<module name="WhitespaceAfter"/>
<module name="WhitespaceAround"/>
<module name="WhitespaceAround">
<property name="tokens"
value="ASSIGN, BAND, BAND_ASSIGN, BOR, BOR_ASSIGN, BSR, BSR_ASSIGN, BXOR, BXOR_ASSIGN,
COLON, DIV, DIV_ASSIGN, DO_WHILE, EQUAL, GE, GT, LAND, LCURLY, LE, LITERAL_CATCH,
LITERAL_DO, LITERAL_ELSE, LITERAL_FINALLY, LITERAL_FOR, LITERAL_IF, LITERAL_RETURN,
LITERAL_SWITCH, LITERAL_SYNCHRONIZED, LITERAL_TRY, LITERAL_WHILE, LOR, LT, MINUS,
MINUS_ASSIGN, MOD, MOD_ASSIGN, NOT_EQUAL, PLUS, PLUS_ASSIGN, QUESTION, SL, SLIST,
SL_ASSIGN, SR, SR_ASSIGN, STAR, STAR_ASSIGN, LITERAL_ASSERT, TYPE_EXTENSION_AND"/>
</module>


<!-- Modifier Checks -->
Expand Down
4 changes: 3 additions & 1 deletion okcurl/pom.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
Expand Down
41 changes: 20 additions & 21 deletions okcurl/src/main/java/okhttp3/curl/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,6 @@
package okhttp3.curl;

import com.google.common.base.Joiner;
import okhttp3.ConnectionPool;
import okhttp3.Headers;
import okhttp3.MediaType;
import okhttp3.OkHttpClient;
import okhttp3.Protocol;
import okhttp3.Request;
import okhttp3.RequestBody;
import okhttp3.Response;
import okhttp3.internal.http.StatusLine;
import okhttp3.internal.framed.Http2;

import io.airlift.command.Arguments;
import io.airlift.command.Command;
import io.airlift.command.HelpOption;
Expand All @@ -49,6 +38,16 @@
import javax.net.ssl.SSLSocketFactory;
import javax.net.ssl.TrustManager;
import javax.net.ssl.X509TrustManager;
import okhttp3.ConnectionPool;
import okhttp3.Headers;
import okhttp3.MediaType;
import okhttp3.OkHttpClient;
import okhttp3.Protocol;
import okhttp3.Request;
import okhttp3.RequestBody;
import okhttp3.Response;
import okhttp3.internal.framed.Http2;
import okhttp3.internal.http.StatusLine;
import okio.BufferedSource;
import okio.Okio;
import okio.Sink;
Expand Down Expand Up @@ -84,16 +83,16 @@ private static String protocols() {
return Joiner.on(", ").join(Protocol.values());
}

@Option(name = { "-X", "--request" }, description = "Specify request command to use")
@Option(name = {"-X", "--request"}, description = "Specify request command to use")
public String method;

@Option(name = { "-d", "--data" }, description = "HTTP POST data")
@Option(name = {"-d", "--data"}, description = "HTTP POST data")
public String data;

@Option(name = { "-H", "--header" }, description = "Custom header to pass to server")
@Option(name = {"-H", "--header"}, description = "Custom header to pass to server")
public List<String> headers;

@Option(name = { "-A", "--user-agent" }, description = "User-Agent to send to server")
@Option(name = {"-A", "--user-agent"}, description = "User-Agent to send to server")
public String userAgent = NAME + "/" + versionString();

@Option(name = "--connect-timeout", description = "Maximum time allowed for connection (seconds)")
Expand All @@ -102,23 +101,23 @@ private static String protocols() {
@Option(name = "--read-timeout", description = "Maximum time allowed for reading data (seconds)")
public int readTimeout = DEFAULT_TIMEOUT;

@Option(name = { "-L", "--location" }, description = "Follow redirects")
@Option(name = {"-L", "--location"}, description = "Follow redirects")
public boolean followRedirects;

@Option(name = { "-k", "--insecure" },
@Option(name = {"-k", "--insecure"},
description = "Allow connections to SSL sites without certs")
public boolean allowInsecure;

@Option(name = { "-i", "--include" }, description = "Include protocol headers in the output")
@Option(name = {"-i", "--include"}, description = "Include protocol headers in the output")
public boolean showHeaders;

@Option(name = "--frames", description = "Log HTTP/2 frames to STDERR")
public boolean showHttp2Frames;

@Option(name = { "-e", "--referer" }, description = "Referer URL")
@Option(name = {"-e", "--referer"}, description = "Referer URL")
public String referer;

@Option(name = { "-V", "--version" }, description = "Show version number and quit")
@Option(name = {"-V", "--version"}, description = "Show version number and quit")
public boolean version;

@Arguments(title = "url", description = "Remote resource URL")
Expand Down Expand Up @@ -258,7 +257,7 @@ private static SSLSocketFactory createInsecureSslSocketFactory() {
return null;
}
};
context.init(null, new TrustManager[] { permissive }, null);
context.init(null, new TrustManager[] {permissive}, null);
return context.getSocketFactory();
} catch (Exception e) {
throw new AssertionError(e);
Expand Down
2 changes: 1 addition & 1 deletion okcurl/src/test/java/okhttp3/curl/MainTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
*/
package okhttp3.curl;

import java.io.IOException;
import okhttp3.Request;
import okhttp3.RequestBody;
import java.io.IOException;
import okio.Buffer;
import org.junit.Test;

Expand Down
10 changes: 7 additions & 3 deletions okhttp-android-support/pom.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
Expand All @@ -11,7 +13,9 @@

<artifactId>okhttp-android-support</artifactId>
<name>OkHttp Android Platform Support</name>
<description>Classes to support the Android platform's use of OkHttp (not required for most developers).</description>
<description>Classes to support the Android platform's use of OkHttp (not required for most
developers).
</description>

<dependencies>
<dependency>
Expand All @@ -25,7 +29,7 @@
<artifactId>okhttp-urlconnection</artifactId>
<version>${project.version}</version>
</dependency>

<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,8 @@
*/
package okhttp3;

import okhttp3.internal.huc.CacheAdapter;

import java.net.ResponseCache;
import okhttp3.internal.huc.CacheAdapter;

/**
* Back doors to enable the use of OkHttp within the Android platform libraries. OkHttp is used to
Expand Down
Loading

0 comments on commit 98ae0fb

Please sign in to comment.