From 202d52d118a1da38a151f1d807bf7276a47d80a0 Mon Sep 17 00:00:00 2001 From: Jan-Erik Rediger Date: Tue, 5 May 2020 16:03:12 +0200 Subject: [PATCH] Remove service-glean's hard-dependency on httpurlconnection We still test with it, so we keep it around. There is no change for users: * If they configure an HTTP client it will be used * If they don't, the default of Glean proper will be used (which is a small shim around java.net.HttpURLConnection itself) Fixes #6660 (at least partly) --- components/service/glean/build.gradle | 2 +- .../components/service/glean/config/Configuration.kt | 11 ++++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/components/service/glean/build.gradle b/components/service/glean/build.gradle index 147ee04c3f2..4d83379961d 100644 --- a/components/service/glean/build.gradle +++ b/components/service/glean/build.gradle @@ -53,7 +53,6 @@ dependencies { implementation project(':support-ktx') implementation project(':support-base') implementation project(':concept-fetch') - implementation project(':lib-fetch-httpurlconnection') implementation project(':support-utils') testImplementation Dependencies.androidx_test_core @@ -65,6 +64,7 @@ dependencies { testImplementation Dependencies.androidx_work_testing testImplementation project(':support-test') + testImplementation project(':lib-fetch-httpurlconnection') testImplementation project(':lib-fetch-okhttp') testImplementation GLEAN_LIBRARY_FORUNITTESTS diff --git a/components/service/glean/src/main/java/mozilla/components/service/glean/config/Configuration.kt b/components/service/glean/src/main/java/mozilla/components/service/glean/config/Configuration.kt index 21a5fdc4805..72bb3576f42 100644 --- a/components/service/glean/src/main/java/mozilla/components/service/glean/config/Configuration.kt +++ b/components/service/glean/src/main/java/mozilla/components/service/glean/config/Configuration.kt @@ -4,7 +4,6 @@ package mozilla.components.service.glean.config -import mozilla.components.lib.fetch.httpurlconnection.HttpURLConnectionClient import mozilla.components.service.glean.net.ConceptFetchHttpUploader import mozilla.telemetry.glean.net.PingUploader import mozilla.telemetry.glean.config.Configuration as GleanCoreConfiguration @@ -23,7 +22,7 @@ data class Configuration @JvmOverloads constructor ( val serverEndpoint: String = DEFAULT_TELEMETRY_ENDPOINT, val channel: String? = null, val maxEvents: Int? = null, - val httpClient: PingUploader = ConceptFetchHttpUploader(lazy { HttpURLConnectionClient() }) + val httpClient: PingUploader? = null ) { // The following is required to support calling our API from Java. companion object { @@ -37,6 +36,12 @@ data class Configuration @JvmOverloads constructor ( * @return a [mozilla.telemetry.glean.config.Configuration] instance. */ fun toWrappedConfiguration(): GleanCoreConfiguration { - return GleanCoreConfiguration(serverEndpoint, channel, maxEvents, httpClient) + // Only pass on the HTTP client if one was configured, + // otherwise fall back to the default in Glean core. + if (httpClient != null) { + return GleanCoreConfiguration(serverEndpoint, channel, maxEvents, httpClient) + } else { + return GleanCoreConfiguration(serverEndpoint, channel, maxEvents) + } } }