diff --git a/okhttp-tests/src/test/java/com/squareup/okhttp/CallTest.java b/okhttp-tests/src/test/java/com/squareup/okhttp/CallTest.java index a1ed775de878..61b2cc3d80fb 100644 --- a/okhttp-tests/src/test/java/com/squareup/okhttp/CallTest.java +++ b/okhttp-tests/src/test/java/com/squareup/okhttp/CallTest.java @@ -48,7 +48,6 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicReference; -import java.util.logging.Logger; import javax.net.ssl.SSLContext; import javax.net.ssl.SSLPeerUnverifiedException; import javax.net.ssl.SSLProtocolException; @@ -62,6 +61,7 @@ import org.junit.Ignore; import org.junit.Test; +import static com.squareup.okhttp.internal.Internal.logger; import static java.lang.Thread.UncaughtExceptionHandler; import static java.net.CookiePolicy.ACCEPT_ORIGINAL_SERVER; import static org.junit.Assert.assertEquals; @@ -87,7 +87,7 @@ public final class CallTest { File cacheDir = new File(tmp, "HttpCache-" + UUID.randomUUID()); cache = new Cache(cacheDir, Integer.MAX_VALUE); defaultUncaughtExceptionHandler = Thread.getDefaultUncaughtExceptionHandler(); - Logger.getLogger(OkHttpClient.class.getName()).addHandler(logHandler); + logger.addHandler(logHandler); } @After public void tearDown() throws Exception { @@ -95,7 +95,7 @@ public final class CallTest { server2.shutdown(); cache.delete(); Thread.setDefaultUncaughtExceptionHandler(defaultUncaughtExceptionHandler); - Logger.getLogger(OkHttpClient.class.getName()).removeHandler(logHandler); + logger.removeHandler(logHandler); } @Test public void get() throws Exception { diff --git a/okhttp/src/main/java/com/squareup/okhttp/Call.java b/okhttp/src/main/java/com/squareup/okhttp/Call.java index 46f15a428ced..8719fe785678 100644 --- a/okhttp/src/main/java/com/squareup/okhttp/Call.java +++ b/okhttp/src/main/java/com/squareup/okhttp/Call.java @@ -26,10 +26,10 @@ import java.net.ProtocolException; import java.net.URL; import java.util.logging.Level; -import java.util.logging.Logger; import okio.BufferedSink; import okio.BufferedSource; +import static com.squareup.okhttp.internal.Internal.logger; import static com.squareup.okhttp.internal.http.HttpEngine.MAX_REDIRECTS; /** @@ -169,8 +169,7 @@ Call get() { } catch (IOException e) { if (signalledCallback) { // Do not signal the callback twice! - Logger.getLogger(OkHttpClient.class.getName()) - .log(Level.INFO, "Callback failure for " + toLoggableString(), e); + logger.log(Level.INFO, "Callback failure for " + toLoggableString(), e); } else { responseCallback.onFailure(request, e); } diff --git a/okhttp/src/main/java/com/squareup/okhttp/internal/Internal.java b/okhttp/src/main/java/com/squareup/okhttp/internal/Internal.java index c909b334091e..40a7cbce1585 100644 --- a/okhttp/src/main/java/com/squareup/okhttp/internal/Internal.java +++ b/okhttp/src/main/java/com/squareup/okhttp/internal/Internal.java @@ -24,6 +24,7 @@ import com.squareup.okhttp.internal.http.HttpEngine; import com.squareup.okhttp.internal.http.Transport; import java.io.IOException; +import java.util.logging.Logger; /** * Escalate internal APIs in {@code com.squareup.okhttp} so they can be used @@ -31,6 +32,7 @@ * interface is in {@link com.squareup.okhttp.OkHttpClient}. */ public abstract class Internal { + public static final Logger logger = Logger.getLogger(OkHttpClient.class.getName()); public static Internal instance; public abstract Transport newTransport(Connection connection, HttpEngine httpEngine) diff --git a/okhttp/src/main/java/com/squareup/okhttp/internal/Platform.java b/okhttp/src/main/java/com/squareup/okhttp/internal/Platform.java index 8e3fb35814ef..24617ad0b54c 100644 --- a/okhttp/src/main/java/com/squareup/okhttp/internal/Platform.java +++ b/okhttp/src/main/java/com/squareup/okhttp/internal/Platform.java @@ -16,7 +16,6 @@ */ package com.squareup.okhttp.internal; -import com.squareup.okhttp.OkHttpClient; import com.squareup.okhttp.Protocol; import java.io.IOException; import java.lang.reflect.InvocationHandler; @@ -32,10 +31,11 @@ import java.util.ArrayList; import java.util.List; import java.util.logging.Level; -import java.util.logging.Logger; import javax.net.ssl.SSLSocket; import okio.Buffer; +import static com.squareup.okhttp.internal.Internal.logger; + /** * Access to Platform-specific features necessary for SPDY and advanced TLS. * This includes Server Name Indication (SNI) and session tickets. @@ -328,9 +328,8 @@ public JdkWithJettyBootPlatform(Method putMethod, Method getMethod, JettyNegoProvider provider = (JettyNegoProvider) Proxy.getInvocationHandler(getMethod.invoke(null, socket)); if (!provider.unsupported && provider.selected == null) { - Logger.getLogger(OkHttpClient.class.getName()).log(Level.INFO, - "NPN/ALPN callback dropped: SPDY and HTTP/2 are disabled. " - + "Is npn-boot or alpn-boot on the boot class path?"); + logger.log(Level.INFO, "NPN/ALPN callback dropped: SPDY and HTTP/2 are disabled. " + + "Is npn-boot or alpn-boot on the boot class path?"); return null; } return provider.unsupported ? null : provider.selected; diff --git a/okhttp/src/main/java/com/squareup/okhttp/internal/spdy/Http20Draft14.java b/okhttp/src/main/java/com/squareup/okhttp/internal/spdy/Http20Draft14.java index 4ac76a6465f1..edbdc333cb93 100644 --- a/okhttp/src/main/java/com/squareup/okhttp/internal/spdy/Http20Draft14.java +++ b/okhttp/src/main/java/com/squareup/okhttp/internal/spdy/Http20Draft14.java @@ -18,7 +18,6 @@ import com.squareup.okhttp.Protocol; import java.io.IOException; import java.util.List; -import java.util.logging.Logger; import okio.Buffer; import okio.BufferedSink; import okio.BufferedSource; @@ -26,6 +25,7 @@ import okio.Source; import okio.Timeout; +import static com.squareup.okhttp.internal.Internal.logger; import static com.squareup.okhttp.internal.spdy.Http20Draft14.FrameLogger.formatHeader; import static java.lang.String.format; import static java.util.logging.Level.FINE; @@ -40,8 +40,6 @@ *
http://tools.ietf.org/html/draft-ietf-httpbis-http2-14 */ public final class Http20Draft14 implements Variant { - private static final Logger logger = Logger.getLogger(Http20Draft14.class.getName()); - @Override public Protocol getProtocol() { return Protocol.HTTP_2; }