mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Avoid duplicate destroy on same thread (#38233)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/38233 When call ReactHost.destroy multiple times on same thread, the synchronization we have now can not protect us from concurrent issues such as ```ConcurrentModificationException```, to avoid this case this diff checks if ReactInstance has been reset, if so it means an early destroy has been called and we should not destroy again. Changelog: [Android][Changed] - Avoid duplicate destroy on same thread Reviewed By: fkgozali Differential Revision: D47276191 fbshipit-source-id: 2291b89cb980ca762abddb835e703abd095a93b3
This commit is contained in:
committed by
Facebook GitHub Bot
parent
d491674201
commit
43f7781c87
+7
@@ -1415,6 +1415,13 @@ public class ReactHost implements ReactHostInterface {
|
||||
raiseSoftException(method, reason, ex);
|
||||
|
||||
synchronized (mReactInstanceTaskRef) {
|
||||
// Prevent re-destroy when ReactInstance has been reset already, which could happen when
|
||||
// calling destroy multiple times on the same thread
|
||||
ReactInstance reactInstance = mReactInstanceTaskRef.get().getResult();
|
||||
if (reactInstance == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Retain a reference to current ReactContext before de-referenced by mReactContextRef
|
||||
final ReactContext reactContext = getCurrentReactContext();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user