Don't throw on late singleton registration
authorAndrii Grynenko <andrii@fb.com>
Fri, 6 May 2016 17:26:04 +0000 (10:26 -0700)
committerFacebook Github Bot 2 <facebook-github-bot-2-bot@fb.com>
Fri, 6 May 2016 17:35:29 +0000 (10:35 -0700)
Summary: Having singleton registered after registrationComplete() is called is not a hard failure. Replacing exception with ERROR, since we probably still want to avoid such situation.

Reviewed By: yfeldblum

Differential Revision: D3266376

fb-gh-sync-id: 8130d279775348c835265987c95189bd3d8106f9
fbshipit-source-id: 8130d279775348c835265987c95189bd3d8106f9

folly/Singleton.cpp

index ae60d4c9abae28cd50a82d02d012b44e1a3542e7..df3cbcb059cdd647061402474bf18e3b81d90651 100644 (file)
@@ -78,8 +78,7 @@ void SingletonVault::registerSingleton(detail::SingletonHolderBase* entry) {
   stateCheck(SingletonVaultState::Running);
 
   if (UNLIKELY(registrationComplete_)) {
-    throw std::logic_error(
-      "Registering singleton after registrationComplete().");
+    LOG(ERROR) << "Registering singleton after registrationComplete().";
   }
 
   RWSpinLock::ReadHolder rhMutex(&mutex_);
@@ -96,8 +95,7 @@ void SingletonVault::addEagerInitSingleton(detail::SingletonHolderBase* entry) {
   stateCheck(SingletonVaultState::Running);
 
   if (UNLIKELY(registrationComplete_)) {
-    throw std::logic_error(
-        "Registering for eager-load after registrationComplete().");
+    LOG(ERROR) << "Registering for eager-load after registrationComplete().";
   }
 
   RWSpinLock::ReadHolder rhMutex(&mutex_);