Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions firebase-functions/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Unreleased

- [changed] Bumped dependency on OkHTTP to version 4.12.0 from version 3.12.13. If your app depends
on OkHTTP version 3.x the change is both binary- and Java source-compatible, with a few small
exceptions. See https://square.github.io/okhttp/changelogs/upgrading_to_okhttp_4/ for more
details.

# 22.0.1

- [changed] Bumped internal dependencies.
Expand Down
2 changes: 1 addition & 1 deletion firebase-functions/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
version=22.0.2
version=22.1.0
latestReleasedVersion=22.0.1
android.enableUnitTestBinaryResources=true
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ import java.util.concurrent.Executor
import javax.inject.Named
import okhttp3.Call
import okhttp3.Callback
import okhttp3.MediaType
import okhttp3.MediaType.Companion.toMediaTypeOrNull
import okhttp3.OkHttpClient
import okhttp3.Request
import okhttp3.RequestBody
import okhttp3.RequestBody.Companion.toRequestBody
import okhttp3.Response
import org.json.JSONException
import org.json.JSONObject
Expand Down Expand Up @@ -87,7 +87,7 @@ internal constructor(
try {
URL(regionOrCustomDomain)
false
} catch (malformedURLException: MalformedURLException) {
} catch (_: MalformedURLException) {
true
}
if (isRegion) {
Expand Down Expand Up @@ -227,8 +227,8 @@ internal constructor(
val encoded = serializer.encode(data)
body["data"] = encoded
val bodyJSON = JSONObject(body)
val contentType = MediaType.parse("application/json")
val requestBody = RequestBody.create(contentType, bodyJSON.toString())
val contentType = "application/json".toMediaTypeOrNull()
val requestBody = bodyJSON.toString().toRequestBody(contentType)
Comment on lines +230 to +231
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wondering whether these changes would cause binary incompatibility for devs who have an explicit dependency on okhttp 3.x in their apps.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a good point, from testing and their own documentation, https://square.github.io/okhttp/changelogs/upgrading_to_okhttp_4/#upgrading-to-okhttp-4, the change is pretty much transparent for people using okhttp3 from Java. The change is source breaking for those using Kotlin.

OkHTTP 4.0 was released on June, 2019 and I think it should be safe to assume that Kotlin apps are most likely using that version instead of 3.x, last released mid 2020.

I've updated the changelog message. PTAL

var request = Request.Builder().url(url).post(requestBody)
if (context!!.authToken != null) {
request = request.header("Authorization", "Bearer " + context.authToken)
Expand Down Expand Up @@ -268,8 +268,8 @@ internal constructor(

@Throws(IOException::class)
override fun onResponse(ignored: Call, response: Response) {
val code = fromHttpStatus(response.code())
val bodyAsString = response.body()!!.string()
val code = fromHttpStatus(response.code)
val bodyAsString = response.body!!.string()
val exception = fromResponse(code, bodyAsString, serializer)
if (exception != null) {
tcs.setException(exception)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import java.util.concurrent.Executor
import java.util.concurrent.atomic.AtomicLong
import okhttp3.Call
import okhttp3.Callback
import okhttp3.MediaType
import okhttp3.MediaType.Companion.toMediaTypeOrNull
import okhttp3.OkHttpClient
import okhttp3.Request
import okhttp3.RequestBody
Expand Down Expand Up @@ -133,7 +133,7 @@ internal class PublisherStream(
val configuredClient = options.apply(client)
val requestBody =
RequestBody.create(
MediaType.parse("application/json"),
"application/json".toMediaTypeOrNull(),
JSONObject(mapOf("data" to serializer.encode(data))).toString()
)
val request =
Expand Down Expand Up @@ -167,7 +167,7 @@ internal class PublisherStream(

override fun onResponse(call: Call, response: Response) {
validateResponse(response)
val bodyStream = response.body()?.byteStream()
val bodyStream = response.body?.byteStream()
if (bodyStream != null) {
processSSEStream(bodyStream)
} else {
Expand Down Expand Up @@ -309,21 +309,21 @@ internal class PublisherStream(

val errorMessage: String
if (
response.code() == 404 &&
MediaType.parse(response.header("Content-Type") ?: "")?.subtype() == "html"
response.code == 404 &&
(response.header("Content-Type") ?: "").toMediaTypeOrNull()?.subtype == "html"
) {
errorMessage = """URL not found. Raw response: ${response.body()?.string()}""".trimMargin()
errorMessage = """URL not found. Raw response: ${response.body?.string()}""".trimMargin()
notifyError(
FirebaseFunctionsException(
errorMessage,
FirebaseFunctionsException.Code.fromHttpStatus(response.code()),
FirebaseFunctionsException.Code.fromHttpStatus(response.code),
null
)
)
return
}

val text = response.body()?.string() ?: ""
val text = response.body?.string() ?: ""
val error: Any?
try {
val json = JSONObject(text)
Expand Down
5 changes: 5 additions & 0 deletions firebase-perf/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Unreleased

- [changed] Bumped dependency on OkHTTP to version 4.12.0 from version 3.12.13. If your app depends
on OkHTTP version 3.x the change is both binary- and Java source-compatible, with a few small
exceptions. See https://square.github.io/okhttp/changelogs/upgrading_to_okhttp_4/ for more
details.

# 22.0.2

- [changed] Bumped internal dependencies.
Expand Down
16 changes: 8 additions & 8 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ maven-resolver-provider = { module = "org.apache.maven:maven-resolver-provider",
maven-resolver-transport-file = { module = "org.apache.maven.resolver:maven-resolver-transport-file", version.ref = "mavenResolverApi" }
maven-resolver-transport-http = { module = "org.apache.maven.resolver:maven-resolver-transport-http", version.ref = "mavenResolverApi" }
maven-resolver-util = { module = "org.apache.maven.resolver:maven-resolver-util", version.ref = "mavenResolverApi" }
okhttp = { module = "com.squareup.okhttp3:okhttp", version = "3.12.13" }
okhttp = { module = "com.squareup.okhttp3:okhttp", version = "4.12.0" }
org-json = { module = "org.json:json", version = "20240303" }
play-services-cloud-messaging = { module = "com.google.android.gms:play-services-cloud-messaging", version.ref = "playServicesCloudMessaging" }
play-services-stats = { module = "com.google.android.gms:play-services-stats", version.ref = "playServicesStats" }
Expand Down Expand Up @@ -222,13 +222,13 @@ wiremock-standalone = { module = "com.github.tomakehurst:wiremock-standalone", v
kotest = ["kotest-runner", "kotest-assertions", "kotest-property", "kotest-property-arbs"]
playservices = ["playservices-base", "playservices-basement", "playservices-tasks"]
maven-resolver = [
"maven-resolver-api",
"maven-resolver-connector-basic",
"maven-resolver-impl",
"maven-resolver-provider",
"maven-resolver-transport-file",
"maven-resolver-transport-http",
"maven-resolver-util"
"maven-resolver-api",
"maven-resolver-connector-basic",
"maven-resolver-impl",
"maven-resolver-provider",
"maven-resolver-transport-file",
"maven-resolver-transport-http",
"maven-resolver-util"
]

[plugins]
Expand Down
Loading