Skip to content

Commit 70eec96

Browse files
smilesa-maurice
authored andcommitted
Test for data race on the destruction of Android Auth objects.
PiperOrigin-RevId: 246584949
1 parent 436b1bb commit 70eec96

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

auth/src/android/credential_android.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,7 @@ std::string Credential::provider() const {
293293
jobject j_provider = env->CallObjectMethod(
294294
CredentialFromImpl(impl_),
295295
credential::GetMethodId(credential::kGetSignInMethod));
296+
assert(env->ExceptionCheck() == false);
296297
return JniStringToString(env, j_provider);
297298
}
298299

@@ -613,6 +614,7 @@ PhoneAuthProvider::Listener::~Listener() {
613614
// (which is being destroyed).
614615
env->CallVoidMethod(data_->j_listener,
615616
jniphone::GetMethodId(jniphone::kDisconnect));
617+
assert(env->ExceptionCheck() == false);
616618

617619
// Remove our reference to the Java Listener. Once Auth Java is done with it,
618620
// it will be garbage collected.

auth/src/android/user_android.cc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
* limitations under the License.
1515
*/
1616

17+
#include <assert.h>
18+
1719
#include "app/src/time.h"
1820
#include "auth/src/android/common_android.h"
1921

@@ -286,6 +288,7 @@ void ReadTokenResult(jobject result, FutureCallbackData<std::string>* d,
286288
FIREBASE_ASSERT(result != nullptr);
287289
jstring j_token = static_cast<jstring>(env->CallObjectMethod(
288290
result, tokenresult::GetMethodId(tokenresult::kGetToken)));
291+
assert(env->ExceptionCheck() == false);
289292
*data = JniStringToString(env, j_token);
290293
} else {
291294
*data = std::string();
@@ -323,18 +326,21 @@ const std::vector<UserInfoInterface*>& User::provider_data() const {
323326
// getProviderData returns `List<? extends UserInfo>`
324327
const jobject list = env->CallObjectMethod(
325328
UserImpl(auth_data_), user::GetMethodId(user::kProviderData));
329+
assert(env->ExceptionCheck() == false);
326330

327331
// Copy the list into auth_data_->user_infos.
328332
if (list != nullptr) {
329333
const int num_providers =
330334
env->CallIntMethod(list, util::list::GetMethodId(util::list::kSize));
335+
assert(env->ExceptionCheck() == false);
331336
auth_data_->user_infos.resize(num_providers);
332337

333338
for (int i = 0; i < num_providers; ++i) {
334339
// user_info is converted to a global reference in
335340
// AndroidWrappedUserInfo() and the local reference is released.
336341
jobject user_info = env->CallObjectMethod(
337342
list, util::list::GetMethodId(util::list::kGet), i);
343+
assert(env->ExceptionCheck() == false);
338344
auth_data_->user_infos[i] =
339345
new AndroidWrappedUserInfo(auth_data_, user_info);
340346
}
@@ -664,8 +670,10 @@ UserMetadata User::metadata() const {
664670
UserMetadata data;
665671
data.last_sign_in_timestamp = env->CallLongMethod(
666672
userMetadata, metadata::GetMethodId(metadata::kGetLastSignInTimestamp));
673+
assert(env->ExceptionCheck() == false);
667674
data.creation_timestamp = env->CallLongMethod(
668675
userMetadata, metadata::GetMethodId(metadata::kGetCreationTimestamp));
676+
assert(env->ExceptionCheck() == false);
669677

670678
env->DeleteLocalRef(userMetadata);
671679

0 commit comments

Comments
 (0)