From 8d90d07e9476f829f0fc7af7bf7efe6ad60e195a Mon Sep 17 00:00:00 2001 From: Andrii Grynenko Date: Fri, 6 May 2016 10:26:04 -0700 Subject: [PATCH] Don't throw on late singleton registration 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 | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/folly/Singleton.cpp b/folly/Singleton.cpp index ae60d4c9..df3cbcb0 100644 --- a/folly/Singleton.cpp +++ b/folly/Singleton.cpp @@ -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_); -- 2.34.1