Skip to content

Commit

Permalink
Remove service-glean's hard-dependency on httpurlconnection
Browse files Browse the repository at this point in the history
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 mozilla-mobile#6660 (at least partly)
  • Loading branch information
badboy committed May 5, 2020
1 parent 5bf5c42 commit 202d52d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion components/service/glean/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 {
Expand All @@ -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)
}
}
}

0 comments on commit 202d52d

Please sign in to comment.