Clear OOME from DexCache allocation when another thread succeeded.
Test: m test-art-host
Change-Id: I358f69de446474641fab7ca6a9eadf15c9900b87
diff --git a/runtime/class_linker.cc b/runtime/class_linker.cc
index cea8377..9f49b04 100644
--- a/runtime/class_linker.cc
+++ b/runtime/class_linker.cc
@@ -3242,6 +3242,10 @@
WriterMutexLock mu(self, dex_lock_);
ObjPtr<mirror::DexCache> dex_cache = FindDexCacheLocked(self, dex_file, true);
if (dex_cache != nullptr) {
+ // Another thread managed to initialize the dex cache faster, so use that DexCache.
+ // If this thread encountered OOME, ignore it.
+ DCHECK_EQ(h_dex_cache.Get() == nullptr, self->IsExceptionPending());
+ self->ClearException();
return dex_cache.Ptr();
}
if (h_dex_cache.Get() == nullptr) {