Skip to content

Commit d6caac7

Browse files
committed
fix OKHttp response fail: java.lang.IllegalStateException: closed
1 parent 3f59ec4 commit d6caac7

File tree

2 files changed

+15
-16
lines changed

2 files changed

+15
-16
lines changed

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
version=0.4.3
1+
version=0.4.4

src/main/java/com/google/firebase/auth/FirebaseAuth.kt

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -348,21 +348,20 @@ class FirebaseAuth constructor(val app: FirebaseApp) : InternalAuthProvider {
348348

349349
@Throws(IOException::class)
350350
override fun onResponse(call: Call, response: Response) {
351-
response.body().use { body ->
352-
if (!response.isSuccessful) {
353-
signOutAndThrowInvalidUserException(body?.string().orEmpty(), "token API returned an error: ${body?.string()}")
354-
} else {
355-
jsonParser.parseToJsonElement(body!!.string()).jsonObject.apply {
356-
val user = FirebaseUserImpl(app, this, user.isAnonymous)
357-
if (user.claims["aud"] != app.options.projectId) {
358-
signOutAndThrowInvalidUserException(
359-
user.claims.toString(),
360-
"Project ID's do not match ${user.claims["aud"]} != ${app.options.projectId}"
361-
)
362-
} else {
363-
this@FirebaseAuth.user = user
364-
source.setResult(user)
365-
}
351+
val body = response.body()?.use { it.string() }
352+
if (!response.isSuccessful) {
353+
signOutAndThrowInvalidUserException(body.orEmpty(), "token API returned an error: $body")
354+
} else {
355+
jsonParser.parseToJsonElement(body!!).jsonObject.apply {
356+
val user = FirebaseUserImpl(app, this, user.isAnonymous)
357+
if (user.claims["aud"] != app.options.projectId) {
358+
signOutAndThrowInvalidUserException(
359+
user.claims.toString(),
360+
"Project ID's do not match ${user.claims["aud"]} != ${app.options.projectId}"
361+
)
362+
} else {
363+
this@FirebaseAuth.user = user
364+
source.setResult(user)
366365
}
367366
}
368367
}

0 commit comments

Comments
 (0)